Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java	(revision 35320)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java	(revision 35321)
@@ -42,6 +42,7 @@
          * @param imageryId imagery id
          * @return the API key for the given imagery id
-         */
-        String retrieveApiKey(String imageryId);
+         * @throws IOException in case of I/O error
+         */
+        String retrieveApiKey(String imageryId) throws IOException;
     }
 
@@ -191,6 +192,7 @@
      * @param imageryId imagery id
      * @return the API key for the given imagery id
-     */
-    public static String retrieveApiKey(String imageryId) {
+     * @throws IOException in case of I/O error
+     */
+    public static String retrieveApiKey(String imageryId) throws IOException {
         return apiKeyAdapter.retrieveApiKey(imageryId);
     }
Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java	(revision 35320)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java	(revision 35321)
@@ -2,4 +2,5 @@
 package org.openstreetmap.gui.jmapviewer.tilesources;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -93,7 +94,11 @@
         });
         // Capturing group pattern on API key values
-        replacePattern(PATTERN_API_KEY, (matcher, output) ->
-            matcher.appendReplacement(output, FeatureAdapter.retrieveApiKey(imageryId))
-        );
+        replacePattern(PATTERN_API_KEY, (matcher, output) -> {
+            try {
+                matcher.appendReplacement(output, FeatureAdapter.retrieveApiKey(imageryId));
+            } catch (IOException e) {
+                throw new IllegalArgumentException(e);
+            }
+        });
         // Capturing group pattern on zoom values
         m = PATTERN_ZOOM.matcher(baseUrl);
