Unable to instantiate ArcGISMap from this webMapUrl

242
1
Jump to solution
03-19-2024 05:54 AM
ErelUziel
New Contributor

I'm just starting with the Java SDK. I'm using OpenJDK 19.0.2. The map loads fine when running from the IDE. Once I build a standalone package using jlink, things start to act strangely. It works most of the times, but from time to time it fails to start and gives this error:

java.lang.IllegalArgumentException: Unable to instantiate ArcGISMap from this webMapUrl
at b4j/com.esri.arcgisruntime.mapping.ArcGISMap.<init>(Unknown Source)
... 28 more

Is there any way to get more information about the cause of failure?

0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor

I've added some code below which shows you how to check the cause of an error when loading a Portal or a PortalItem

Portal portal = new Portal("https://www.arcgis.com/");
      System.out.println("loading portal");
      portal.loadAsync();
      portal.addDoneLoadingListener(()-> {
        //check status of portal loading
        System.out.println("Portal load status " + portal.getLoadStatus());
        if (portal.getLoadStatus() == LoadStatus.LOADED) {
          // portal loaded okay so let's try the portal item
          PortalItem portalItem = new PortalItem(portal, "92ad152b9da94dee89b9e387dfe21acd");
          portalItem.loadAsync();
          portalItem.addDoneLoadingListener(()-> {
            // check portal item load status
            System.out.println("portal item load status " + portalItem.getLoadStatus());
            if (portalItem.getLoadStatus() == LoadStatus.LOADED) {
              // make map from portal item and add to mapview it displays
              ArcGISMap map = new ArcGISMap(portalItem);
              mapView = new MapView();
              mapView.setMap(map);

              // add the map view to the stack pane
              stackPane.getChildren().addAll(mapView);

            } else {
              System.out.println("portal item failed to load");
              System.out.println(portalItem.getLoadError().getCause());
            }
          });
        } else {
          System.out.println("portal failed to load");
          System.out.println(portal.getLoadError().getCause());
        }
      });

 

I'm not sure why you are specifically getting the error above, but you might get some clues from the code above.

I would also not use Java 19, this isn't an LTS release and isn't supported.  Ideally you should be using Java 21.

You should also read this blog post which says that we are about to deprecate the Java SDK, so you should consider an alternative technology for new projects.

Does this help?

View solution in original post

0 Kudos
1 Reply
MarkBaird
Esri Regular Contributor

I've added some code below which shows you how to check the cause of an error when loading a Portal or a PortalItem

Portal portal = new Portal("https://www.arcgis.com/");
      System.out.println("loading portal");
      portal.loadAsync();
      portal.addDoneLoadingListener(()-> {
        //check status of portal loading
        System.out.println("Portal load status " + portal.getLoadStatus());
        if (portal.getLoadStatus() == LoadStatus.LOADED) {
          // portal loaded okay so let's try the portal item
          PortalItem portalItem = new PortalItem(portal, "92ad152b9da94dee89b9e387dfe21acd");
          portalItem.loadAsync();
          portalItem.addDoneLoadingListener(()-> {
            // check portal item load status
            System.out.println("portal item load status " + portalItem.getLoadStatus());
            if (portalItem.getLoadStatus() == LoadStatus.LOADED) {
              // make map from portal item and add to mapview it displays
              ArcGISMap map = new ArcGISMap(portalItem);
              mapView = new MapView();
              mapView.setMap(map);

              // add the map view to the stack pane
              stackPane.getChildren().addAll(mapView);

            } else {
              System.out.println("portal item failed to load");
              System.out.println(portalItem.getLoadError().getCause());
            }
          });
        } else {
          System.out.println("portal failed to load");
          System.out.println(portal.getLoadError().getCause());
        }
      });

 

I'm not sure why you are specifically getting the error above, but you might get some clues from the code above.

I would also not use Java 19, this isn't an LTS release and isn't supported.  Ideally you should be using Java 21.

You should also read this blog post which says that we are about to deprecate the Java SDK, so you should consider an alternative technology for new projects.

Does this help?

0 Kudos