ArcGIS Runtime for Java 10.2 examples not working

5877
16
11-05-2013 02:21 PM
BrunoMendes
Occasional Contributor
I've just installed ArcGIS Runtime for Java 10.2 and tried to open the samples, but none of them displays a map, just ESRI logo.

I've also guaranteed that I have access to the requested domain (in the first sample case, 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer').

For samples that use LocalServer I've assured the server is up and running at 'http://127.0.0.1:50000/9gSy7s/arcgis/rest/services'.

Nothing is printed at the Java console mentioning any error.

What could be the problem?


Thanks in advance.
0 Kudos
16 Replies
MarkBaird
Esri Regular Contributor
The fact that you can see the esri logo suggests that there isn't too much wrong.  I'm wondering if there is a network / firewall issue here.  Are you working in a locked down environment?

How are you running the sample application.  Via a Start menu or using java -jar?

When you say you don't see anything in the console window is this the console you called java -jar, or is it the console window you can open up in the sample application?

If there are really no clues, then I would encourage you to install the eclipse plugin and create a template application.  Running it through eclipse should give you more clues as to what is happening.

Another issue I've seen in locked down environments is when the firewall is using page forwarding.  For example if you went to a web page and requested http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer it goes to another page first which displays the text "forwarding to..." and then your web page opens up.  This kind of works for web browsers, but it's not so good for REST endpoints!  If we make a REST call and the page returns "forwarding to..." it upsets the JSON parser.  You would be able to see this kind of issue by using a tool like Fiddler and browsing to the REST endpoints.

Another thing you could try is looking at the sample which uses just a local tiled package.  In the sample go to Tiled Layers -> Local Tiled Layers and this should work as there is no network connection needed here.

Let me now how you get on.

Mark
0 Kudos
BrunoMendes
Occasional Contributor
Thanks for your considerations Mark,

The fact that you can see the esri logo suggests that there isn't too much wrong. I'm wondering if there is a network / firewall issue here. Are you working in a locked down environment?
Yes.

How are you running the sample application. Via a Start menu or using java -jar?
The sample app was run using the Start menu.

When you say you don't see anything in the console window is this the console you called java -jar, or is it the console window you can open up in the sample application?
It was the console window in the sample app.
I have just tried with java -jar and no erro message appeared at all.

If there are really no clues, then I would encourage you to install the eclipse plugin and create a template application. Running it through eclipse should give you more clues as to what is happening.
After installed the eclipse plugin in my Kepler, I've created a Map Application and tested the following approaches:
1. Internet http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer;
2. Intranet http://<server-ip>/ArcGIS/rest/services/Basemap/ManausBasemap/MapServer;
3. Offline C:\\Program Files (x86)\\ArcGIS SDKs\\java10.2\\sdk\\samples\\data\\mpks\\USCitiesStates.mpk.

None of them presents errors messages. All of them show ESRI logo.
*I've noticed some warning messages about beta functionality and one message that looks like an expected exception: datadir does not exist, creating: "C:\Users\<user>\AppData\Local\Temp\arcgisruntime_4492"

Another issue I've seen in locked down environments is when the firewall is using page forwarding. For example if you went to a web page and requested http://services.arcgisonline.com/Arc..._Map/MapServer it goes to another page first which displays the text "forwarding to..." and then your web page opens up. This kind of works for web browsers, but it's not so good for REST endpoints! If we make a REST call and the page returns "forwarding to..." it upsets the JSON parser. You would be able to see this kind of issue by using a tool like Fiddler and browsing to the REST endpoints.

Didn't know about this and will have to install Fiddler to test it, but I've tested using CURL in command line and I've got the HTML normally, maybe CURL do handle 'forwarding to...'

Another thing you could try is looking at the sample which uses just a local tiled package. In the sample go to Tiled Layers -> Local Tiled Layers and this should work as there is no network connection needed here.
Same issue and local server is up and running.
0 Kudos
MarkBaird
Esri Regular Contributor
Oh we like a challenge 🙂

Okay some more questions. 

- What JDK/ JRE version are you using?

- What platform are you running on?

- Is it a real machine or a virtual one?

- When you run your application via eclipse, what console output do you see.  On my Windows machine I see the following for example:

[INDENT]Java version : 1.7.0_40 (Oracle Corporation) amd64
Rendering engine : DirectX[/INDENT]

- Have you ever managed to get runtime applications working on older releases?

Mark
0 Kudos
VijayGandhi
New Contributor III
Could you also trying changing the rendering engine. By default, ArcGIS Runtime uses DirectX on Windows. You could switch to OpenGL -
using API (when application starts): ArcGISRuntime.setRenderEngine(RenderEngine.OpenGL), or
using command line (also works with samples jar): -Dcom.esri.runtime.renderEngine=opengl

OpenGL has to be at least 2.1 or 3.3 based on graphics card (https://developers.arcgis.com/en/java/info/arcgis-runtime-sdk-for-java-system-requirements.htm)

Vijay
0 Kudos
BrunoMendes
Occasional Contributor
- What JDK/ JRE version are you using?

java -version output:
[INDENT]java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)[/INDENT]

javac -version output:
[INDENT]javac 1.6.0_30[/INDENT]

- What platform are you running on?

Windows 7 Enterprise 64bits. 4GB RAM. AMD Phenom II x2 560 Processor 3.2GHz.

- Is it a real machine or a virtual one?

Real one.

- When you run your application via eclipse, what console output do you see.  On my Windows machine I see the following for example:

[INDENT]Java version : 1.7.0_40 (Oracle Corporation) amd64
Rendering engine : DirectX[/INDENT]


This eclipse is configured to use JDK7:
[INDENT]Java version : 1.7.0_25 (Oracle Corporation) amd64
Rendering engine : DirectX[/INDENT]
Edit: I've just updated my VM to 1.7.0_45 and the problem persists.

- Have you ever managed to get runtime applications working on older releases?

It is my first attempt to use Runtime Applications. Luckily - or sadly - ArcGIS Runtime for Java SDKv10.2 was released one day before I started searching for it.
0 Kudos
BrunoMendes
Occasional Contributor
Could you also trying changing the rendering engine. By default, ArcGIS Runtime uses DirectX on Windows. You could switch to OpenGL -
using API (when application starts): ArcGISRuntime.setRenderEngine(RenderEngine.OpenGL), or
using command line (also works with samples jar): -Dcom.esri.runtime.renderEngine=opengl

OpenGL has to be at least 2.1 or 3.3 based on graphics card (https://developers.arcgis.com/en/java/info/arcgis-runtime-sdk-for-java-system-requirements.htm)

Vijay


With both JDK6 and JDK7 I get the following error (via command line or eclipse):
[INDENT]Java version : 1.7.0_45 (Oracle Corporation) amd64
Rendering engine : OpenGL
java.lang.RuntimeException: Failed to create shared context
at com.esri.map.JMap.nativeCreateMap(Native Method)
at com.esri.map.JMap.<init>(Unknown Source)
at Main.<init>(Main.java:44)
at Main$2.run(Main.java:67)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)[/INDENT]

Can you give me guidance on how can I check my OpenGL version and how can I update it?

I'm currently downloading the newest driver for my graphics card.
0 Kudos
MarkBaird
Esri Regular Contributor
The error you are seeing above (Failed to create a shared context) is due to the fact that your graphics card drivers are not supporting a very high version of OpenGL.  I bet you only have 1.1 support!  DirectX is usually most reliable in Windows, however as Vijay suggested it was worth a try switching to OpenGL!  The fact that you can see the esri logo when running in DirectX suggests to me that you don't have a rendering issue with DirectX mode.

I'm thinking that your locked down environment is hurting you here.  What I would suggest is creating a application which uses an online service like this:

        map = new JMap();
        window.getContentPane().add(map);

        ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer(
            "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
        map.getLayers().add(tiledLayer);

You then need to configure Eclipse so you can capture the HTTP traffic in Fiddler.  You need to set your JVM run options so you use this:

  -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Then watch if anything gets captured in Fiddler!

One thing I am surprised about is that you couldn't run an application which used a local tiled package.  This just uses basic file IO to read the the TPK file.  This does not use the local server and hence does not rely on HTTP traffic. 

Mark
0 Kudos
MarkBaird
Esri Regular Contributor
Before you go down the Fiddler route can you try this code:

ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
    tiledLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {
     
      @Override
      public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
        System.out.println(e.getLayer().getInitializationError()); // print out any layer init error
      }
    });
map.getLayers().add(tiledLayer);


It might just give some more information.

Mark
0 Kudos
BrunoMendes
Occasional Contributor
Before you go down the Fiddler route can you try this code:

ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
    tiledLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {
     
      @Override
      public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
        System.out.println(e.getLayer().getInitializationError()); // print out any layer init error
      }
    });
map.getLayers().add(tiledLayer);


It might just give some more information.

Mark


I have tested the following code and it prints 'null'. Today afternoon I'll try to capture the packets with Fiddler.
0 Kudos