URI is not hierarchical error while exporting java destop application

4469
6
Jump to solution
07-07-2013 10:23 PM
Highlighted
by Anonymous User
Not applicable
Original User: ishan00kaushik

Hi,

I generated a destop application using java swing and arcobject library within eclipse. It runs smoothly on eclipse but while running the exported jar file in console , it produces error . following is my error report from console---

  java.lang.IllegalArgumentException: URI is not hierarchical         at java.io.File.<init>(File.java:392)         at com.esri.arcgis.interop.NativeLoader.getArcGISHome(Unknown Source)         at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)         at com.esri.arcgis.system.EngineInitializer.initializeEngine(Unknown Source)         at SdeOrPgdb.main(SdeOrPgdb.java:70)         at BrowsePath.actionPerformed(BrowsePath.java:317)         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)         at java.awt.Component.processMouseEvent(Component.java:6505)         at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)         at java.awt.Component.processEvent(Component.java:6270)         at java.awt.Container.processEvent(Container.java:2229)         at java.awt.Component.dispatchEventImpl(Component.java:4861)         at java.awt.Container.dispatchEventImpl(Container.java:2287)         at java.awt.Component.dispatchEvent(Component.java:4687)         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)          at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)         at java.awt.Container.dispatchEventImpl(Container.java:2273)         at java.awt.Window.dispatchEventImpl(Window.java:2719)         at java.awt.Component.dispatchEvent(Component.java:4687)         at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)         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.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)         at java.awt.EventQueue$4.run(EventQueue.java:708)         at java.awt.EventQueue$4.run(EventQueue.java:706)         at java.security.AccessController.doPrivileged(Native Method)         at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)         at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)         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) Error: null Sample failed.  Exiting... java.lang.NullPointerException         at com.esri.arcgis.interop.NativeLoader.getArcGISHome(Unknown Source)         at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)         at com.esri.arcgis.system.EngineInitializer.initializeEngine(Unknown Source)         at SdeOrPgdb.main(SdeOrPgdb.java:70)         at BrowsePath.actionPerformed(BrowsePath.java:317)         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)         at java.awt.Component.processMouseEvent(Component.java:6505)         at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)         at java.awt.Component.processEvent(Component.java:6270)         at java.awt.Container.processEvent(Container.java:2229)         at java.awt.Component.dispatchEventImpl(Component.java:4861)         at java.awt.Container.dispatchEventImpl(Container.java:2287)         at java.awt.Component.dispatchEvent(Component.java:4687)         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)          at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)         at java.awt.Container.dispatchEventImpl(Container.java:2273)         at java.awt.Window.dispatchEventImpl(Window.java:2719)         at java.awt.Component.dispatchEvent(Component.java:4687)         at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)         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.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)         at java.awt.EventQueue$4.run(EventQueue.java:708)         at java.awt.EventQueue$4.run(EventQueue.java:706)         at java.security.AccessController.doPrivileged(Native Method)         at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)         at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)         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) 


Kindly tell how resolve this issue.

Following is my how i am getting a runnable jar file and my project setup in eclipse////
[ATTACH=CONFIG]25780[/ATTACH]
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
by Anonymous User
Not applicable
Original User: ishan00kaushik

Thanks for Replies , the issue has been resolved , it was due to setting some PATH variable were not available .

I followed this link to resolve error.

http://support.esri.com/en/knowledgebase/techarticles/detail/29348

Hope it helps others.

View solution in original post

Reply
0 Kudos
6 Replies
Highlighted
by Anonymous User
Not applicable
Original User: ldonahue

That error means you are not initializing your ArcObjects library correctly.

The Java Deployment Guide talks about two options for deployment.  Which one are you using?
Reply
0 Kudos
Highlighted
New Contributor
None , i am creating jar file with custom eclipse option "runnable jar file" which creates manifest by default.
Is it customary to follow Developement guide steps ?
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: ishan00kaushik

OK , i tried Bootstrap methord by loading arcobject library dynamically before executing arcobject code , but its unable to read arcobject library .
Error is coming the same URI is not hirarichal.
Reply
0 Kudos
Highlighted
New Contributor
Following is my code which i am trying


public class SdeOrPgdb {
 
public SdeOrPgdb(){

}

public static void main(String[] args) {

  try{
  
   bootstrapArcobjectsJar();
   //Initialize engine console application
   EngineInitializer.initializeEngine();
   //Initialize ArcGIS license
   AoInitialize aoInit = new AoInitialize();
   initializeArcGISLicenses(aoInit);
   SdeOrPgdb accessFileGDB = new SdeOrPgdb();
  
   accessFileGDB.openFromFile_sde_Workspace();
     
   System.out.println("Done.");  
  
   //Ensure any ESRI libraries are unloaded in the correct order
   aoInit.shutdown();
               }catch(Exception e){  
   System.out.println("Error: " + e.getMessage());
   System.out.println("Sample failed.  Exiting...");
   e.printStackTrace();
   System.exit(-1);
  }
}

private static void initializeArcGISLicenses(AoInitialize aoInit) {
  try {
   if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine)
     == esriLicenseStatus.esriLicenseAvailable)
    aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
   else if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView)
     == esriLicenseStatus.esriLicenseAvailable)
    aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);
   else{
    System.err.println("Could not initialize an Engine or ArcView license. Exiting application.");
    System.exit(-1);
   }
  } catch (Exception e) {e.printStackTrace();}
}


public static void bootstrapArcobjectsJar(){

        //Get the ArcGIS Engine runtime, if it is available
        String arcObjectsHome = System.getenv("AGSENGINEJAVA");

        //If no runtime is available, exit application gracefully
        if (arcObjectsHome == null){
            System.err.println(
                "You must have the ArcGIS Engine Runtime installed in order to execute this application.");
            System.err.println(
                "Install the product above, then re-run this application.");
            System.err.println("Exiting execution of this application...");
            System.exit( - 1);
        }

        //Obtain the relative path to the arcobjects.jar file
        String jarPath = arcObjectsHome + "java" + File.separator + "lib" +
            File.separator + "arcobjects.jar";

        //Create a new file
        File jarFile = new File(jarPath);

        //Test for file existence
        if (!jarFile.exists()){
            System.err.println(
                "The arcobjects.jar was not found in the following location: " +
                jarFile.getParent());
            System.err.println(
                "Verify that arcobjects.jar can be located in the specified folder.")
                ;
            System.err.println(
                "If not present, try uninstalling your ArcGIS software and reinstalling it.");
            System.err.println("Exiting execution of this application...");
            System.exit( - 1);
        }

        //Helps load classes and resources from a search path of URLs
        URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader()
            ;
        Class < URLClassLoader > sysclass = URLClassLoader.class;

        try{
            Method method = sysclass.getDeclaredMethod("addURL", new Class[]{
                URL.class
            }
            );
            method.setAccessible(true);
            method.invoke(sysloader, new Object[]{
                jarFile.toURI().toURL()
            }
            );
        }
        catch (Throwable throwable){
            throwable.printStackTrace();
            System.err.println("Could not add arcobjects.jar to system classloader");
            System.err.println("Exiting execution of this application...");
            System.exit( - 1);
        }
    }



and following is my error stack after running jar file from command promt--

java.lang.IllegalArgumentException: URI is not hierarchical at java.io.File.<init>(File.java:392)
        at com.esri.arcgis.interop.NativeLoader.getArcGISHome(Unknown Source)
        at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)
        at com.esri.arcgis.system.EngineInitializer.initializeEngine(Unknown Source)
        at SdeOrPgdb.main(SdeOrPgdb.java:70)
        at BrowsePath.actionPerformed(BrowsePath.java:317)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6505)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
        at java.awt.Component.processEvent(Component.java:6270)
        at java.awt.Container.processEvent(Container.java:2229)
        at java.awt.Component.dispatchEventImpl(Component.java:4861)
        at java.awt.Container.dispatchEventImpl(Container.java:2287)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
        at java.awt.Container.dispatchEventImpl(Container.java:2273)
        at java.awt.Window.dispatchEventImpl(Window.java:2719)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
        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.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.awt.EventQueue$4.run(EventQueue.java:708)
        at java.awt.EventQueue$4.run(EventQueue.java:706)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
        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)


Note : "SdeOrPgdb.main(SdeOrPgdb.java:70) " in code is  "EngineInitializer.initializeEngine();"
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: ldonahue

I don't think you can bootstrap in the class you are trying to run.  Re-read the page where it says this:



        //Replace the following line with the name of your main application.         // App.main(args);         Globe3DEventBug.main(args);


You need to call SdeOrPgdb.main(args); from the main method of a class that just has the bootstrap code.

Next, when I initialize it looks like this:


public class Console {

    public static void main(String[] args) {
       
        System.setSecurityManager(null);
       
        try{
            //Step 1: Initialize the Java Componet Object Model (COM) Interop.
            EngineInitializer.initializeEngine();

            //Step 2: Initialize an ArcGIS license.
            AoInitialize aoInit = new AoInitialize();
            initializeArcGISLicenses(aoInit);

            //Step 3: Invoke ArcObjects.
            Do ArcObjects stuff here...

            //Step 4: Release the license.
            aoInit.shutdown();
           
            EngineInitializer.releaseAll();
        }
        catch (IOException ex){
            System.out.println(ex.getMessage());
            System.out.println("App failed.");
        }
    }

    static void initializeArcGISLicenses(AoInitialize aoInit){
        try{
            if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcInfo) == esriLicenseStatus.esriLicenseAvailable){
                aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);
            }
            else{
                System.err.println("ArcInfo license not initialized.");
                System.err.println("Exiting application.");
                System.exit( - 1);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }

}


So, from this example, I would call Console.main in the main method of my bootstrapper class.
Reply
0 Kudos
Highlighted
by Anonymous User
Not applicable
Original User: ishan00kaushik

Thanks for Replies , the issue has been resolved , it was due to setting some PATH variable were not available .

I followed this link to resolve error.

http://support.esri.com/en/knowledgebase/techarticles/detail/29348

Hope it helps others.

View solution in original post

Reply
0 Kudos