Index: trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 13356)
+++ trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 13358)
@@ -17,5 +17,4 @@
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.apache.commons.jcs.access.behavior.ICacheAccess;
@@ -52,12 +51,4 @@
     protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = TimeUnit.DAYS.toMillis(365);
 
-    // Pattern to detect Tomcat error message. Be careful with change of format:
-    // CHECKSTYLE.OFF: LineLength
-    // https://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?r1=1740707&r2=1779641&pathrev=1779641&diff_format=h
-    // CHECKSTYLE.ON: LineLength
-    protected static final Pattern TOMCAT_ERR_MESSAGE = Pattern.compile(
-        ".*<p><b>[^<]+</b>[^<]+</p><p><b>[^<]+</b> (?:<u>)?([^<]*)(?:</u>)?</p><p><b>[^<]+</b> (?:<u>)?[^<]*(?:</u>)?</p>.*",
-        Pattern.CASE_INSENSITIVE);
-
     /**
      * maximum download threads that will be started
@@ -370,5 +361,5 @@
                         String data = urlConn.fetchContent();
                         if (!data.isEmpty()) {
-                            Matcher m = TOMCAT_ERR_MESSAGE.matcher(data);
+                            Matcher m = HttpClient.getTomcatErrorMatcher(data);
                             if (m.matches()) {
                                 attributes.setErrorMessage(m.group(1).replace("'", "''"));
Index: trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java	(revision 13356)
+++ trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java	(revision 13358)
@@ -18,4 +18,5 @@
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -121,4 +122,5 @@
     private URL serviceUrl;
     private List<String> formats;
+    private String version = "1.1.1";
 
     /**
@@ -136,4 +138,13 @@
     public URL getServiceUrl() {
         return serviceUrl;
+    }
+
+    /**
+     * Returns the WMS version used.
+     * @return the WMS version used (1.1.1 or 1.3.0)
+     * @since 13358
+     */
+    public String getVersion() {
+        return version;
     }
 
@@ -198,7 +209,7 @@
     public String buildGetMapUrl(Collection<LayerDetails> selectedLayers, String format) {
         return buildRootUrl() + "FORMAT=" + format + (imageFormatHasTransparency(format) ? "&TRANSPARENT=TRUE" : "")
-                + "&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS="
+                + "&VERSION=" + version + "&SERVICE=WMS&REQUEST=GetMap&LAYERS="
                 + selectedLayers.stream().map(x -> x.ident).collect(Collectors.joining(","))
-                + "&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}";
+                + "&STYLES=&" + ("1.3.0".equals(version) ? "CRS" : "SRS") + "={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}";
     }
 
@@ -238,26 +249,59 @@
     }
 
+    /**
+     * Attempts WMS GetCapabilities with version 1.1.1 first, then 1.3.0 in case of specific errors.
+     * @param serviceUrlStr WMS service URL
+     * @param getCapabilitiesUrl GetCapabilities URL
+     * @throws IOException if any I/O error occurs
+     * @throws WMSGetCapabilitiesException if any HTTP or parsing error occurs
+     */
     private void doAttemptGetCapabilities(String serviceUrlStr, URL getCapabilitiesUrl)
             throws IOException, WMSGetCapabilitiesException {
+        final String url = getCapabilitiesUrl.toExternalForm();
         final Response response = HttpClient.create(getCapabilitiesUrl).connect();
 
+        // Is the HTTP connection successul ?
         if (response.getResponseCode() >= 400) {
-            throw new WMSGetCapabilitiesException(response.getResponseMessage(), response.fetchContent());
+            // HTTP error for servers handling only WMS 1.3.0 ?
+            String errorMessage = response.getResponseMessage();
+            String errorContent = response.fetchContent();
+            Matcher tomcat = HttpClient.getTomcatErrorMatcher(errorContent);
+            boolean messageAbout130 = errorMessage != null && errorMessage.contains("1.3.0");
+            boolean contentAbout130 = errorContent != null && tomcat != null && tomcat.matches() && tomcat.group(1).contains("1.3.0");
+            if (url.contains("VERSION=1.1.1") && (messageAbout130 || contentAbout130)) {
+                doAttemptGetCapabilities130(serviceUrlStr, url);
+                return;
+            }
+            throw new WMSGetCapabilitiesException(errorMessage, errorContent);
         }
 
         try {
+            // Parse XML capabilities sent by the server
             parseCapabilities(serviceUrlStr, response.getContent());
         } catch (WMSGetCapabilitiesException e) {
-            String url = getCapabilitiesUrl.toExternalForm();
             // ServiceException for servers handling only WMS 1.3.0 ?
             if (e.getCause() == null && url.contains("VERSION=1.1.1")) {
-                doAttemptGetCapabilities(serviceUrlStr, new URL(url.replace("VERSION=1.1.1", "VERSION=1.3.0")));
-                if (serviceUrl.toExternalForm().contains("VERSION=1.1.1")) {
-                    serviceUrl = new URL(serviceUrl.toExternalForm().replace("VERSION=1.1.1", "VERSION=1.3.0"));
-                }
+                doAttemptGetCapabilities130(serviceUrlStr, url);
             } else {
                 throw e;
             }
         }
+    }
+
+    /**
+     * Attempts WMS GetCapabilities with version 1.3.0.
+     * @param serviceUrlStr WMS service URL
+     * @param url GetCapabilities URL
+     * @throws IOException if any I/O error occurs
+     * @throws WMSGetCapabilitiesException if any HTTP or parsing error occurs
+     * @throws MalformedURLException in case of invalid URL
+     */
+    private void doAttemptGetCapabilities130(String serviceUrlStr, final String url)
+            throws IOException, WMSGetCapabilitiesException, MalformedURLException {
+        doAttemptGetCapabilities(serviceUrlStr, new URL(url.replace("VERSION=1.1.1", "VERSION=1.3.0")));
+        if (serviceUrl.toExternalForm().contains("VERSION=1.1.1")) {
+            serviceUrl = new URL(serviceUrl.toExternalForm().replace("VERSION=1.1.1", "VERSION=1.3.0"));
+        }
+        version = "1.3.0";
     }
 
Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 13356)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 13358)
@@ -61,4 +61,12 @@
     private boolean finishOnCloseOutput = true;
 
+    // Pattern to detect Tomcat error message. Be careful with change of format:
+    // CHECKSTYLE.OFF: LineLength
+    // https://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?r1=1740707&r2=1779641&pathrev=1779641&diff_format=h
+    // CHECKSTYLE.ON: LineLength
+    private static final Pattern TOMCAT_ERR_MESSAGE = Pattern.compile(
+        ".*<p><b>[^<]+</b>[^<]+</p><p><b>[^<]+</b> (?:<u>)?([^<]*)(?:</u>)?</p><p><b>[^<]+</b> (?:<u>)?[^<]*(?:</u>)?</p>.*",
+        Pattern.CASE_INSENSITIVE);
+
     static {
         CookieHandler.setDefault(new CookieManager());
@@ -687,3 +695,14 @@
         }
     }
+
+    /**
+     * Returns a {@link Matcher} against predefined Tomcat error messages.
+     * If it matches, error message can be extracted from {@code group(1)}.
+     * @param data HTML contents to check
+     * @return a {@link Matcher} against predefined Tomcat error messages
+     * @since 13358
+     */
+    public static Matcher getTomcatErrorMatcher(String data) {
+        return data != null ? TOMCAT_ERR_MESSAGE.matcher(data) : null;
+    }
 }
