EngineInitializer.initializeEngine();
		try {
			com.esri.arcgis.system.AoInitialize ao = new com.esri.arcgis.system.AoInitialize();
			if (ao.isProductCodeAvailable(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB) == com.esri.arcgis.system.esriLicenseStatus.esriLicenseAvailable)
				ao.initialize(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
		} catch (Exception e) {
			e.printStackTrace();
		}

一般的初始化license如上代码 在本地运行一切ok 但是放到 tomcat上做服务时 便出现Could not load native libraries 的问题

通过网上查询发现了如下的解决方法 加在上面语句的前面  测试通过

public static void InitLiscense() {
		// Get the ArcGIS Engine runtime, if it is available
		String arcObjectsHome = "E:\\Program Files\\ArcGIS\\Desktop10.0\\";

		// 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);
		}

	}


Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐