It seems that the code in AoInitialize has some dependencies that don't like when you are pointing to an arcobjects.jar file that is not in the standard location. I had bundled the jar file in a war file that was deployed to a particular location but that caused me to have all sorts of problems. I removed the arcobjects.jar file from my war file and added the bootstrapping code that I eventually stumbled across on this site and have been able to successfully initialize my license. Now on to my next issue...
VersionManager vm = new VersionManager(); vm.loadVersion(com.esri.arcgis.version.esriProductCode.esriArcGISDesktop, "10.0");
package org.lacsd.services.helpers; import java.io.IOException; import java.net.UnknownHostException; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; import com.esri.arcgis.system.esriLicenseProductCode; import com.esri.arcgis.system.esriLicenseStatus; public class LicenseHelper { /** * Initializes the lowest available ArcGIS License */ public static AoInitialize initializeArcGISLicenses() { EngineInitializer.initializeEngine(); AoInitialize aoInit = null; try { aoInit = new AoInitialize(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { System.out.println("license type: " + esriLicenseStatus.esriLicenseAvailable); if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine) == esriLicenseStatus.esriLicenseAvailable) { aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine); } else if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcServer) == esriLicenseStatus.esriLicenseAvailable) { aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer); } else if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcInfo) == esriLicenseStatus.esriLicenseAvailable) { aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo); } else { System.err.println("Could not initialize an Engine or ArcView license. Exiting application."); System.exit(-1); } // do any extra checkouts here, could probably expand to make sure extension available // aoInit.checkOutExtension(com.esri.arcgis.system.esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork); } catch (Exception e) { e.printStackTrace(); } return aoInit; } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.