在使用SuperMap Objects Java开发web应用时,当将应用部署到Tomcat中运行时,当调用Objects中的方法时,以ObjectsJava 7为例,如果不做特殊处理一定会报下面这个错:
java.lang.UnsatisfiedLinkError: no Wrapj in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at com.supermap.data.Environment.LoadWrapJ(Unknown Source)
at com.supermap.data.Environment.<clinit>(Unknown Source)
at com.supermap.data.InternalHandle.<clinit>(Unknown Source)
at com.supermap.sm3dapd.servicemanage.impl.CWorkspaceProcess.getPublishedWorkspace(CWorkspaceProcess.java:179)
at com.supermap.sm3dapd.dataexchange.component.impl.CDataFileManage.publishDataFiles(CDataFileManage.java:45)
at com.supermap.sm3dapd.dataexchange.service.fileServlet.publishData(fileServlet.java:257)
at com.supermap.sm3dapd.dataexchange.service.fileServlet.doPost(fileServlet.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
这时请不要着急,在Tomcat中做一下简单处理即可:
1、打开Tomcat7/bin/catalina.bat,确认一下里面有没有如下内容:
rem Get standard environment variables
if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome
call "%CATALINA_BASE%\bin\setenv.bat"
goto setenvDone
:checkSetenvHome
if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
:setenvDone
如果没有的话在调用setclasspath.bat这个bat之前添加上述内容即可。
2、打开setenv.bat,如果没有的话请手动创建。将其内容修改如下:
@echo off
rem set tmp variables ISERVER_ROOT
set BIN_DIR=%cd%
set curr=%cd%
cd ..
rem 下面这个路径根据实际情况进行修改
set ISERVER_ROOT=D:\ProgramFiles\SuperMap\7_1_2\supermap_iserver_7.1.2_win64_deploy
cd %BIN_DIR%
rem set JRE
rem if exist "%ISERVER_ROOT%\support\jre\bin\java.exe" set "JRE_HOME=%ISERVER_ROOT%\support\jre"
rem if exist "%ISERVER_ROOT%\support\objectsjava\bin\com.supermap.data.jar" ( goto checkiServerUGO ) else ( goto checkPathUGO )
rem check and set UGO in iServer\support
:checkiServerUGO
set "ObjectsJava_HOME=%ISERVER_ROOT%\support\objectsjava"
set Path=%BIN_DIR%;%ObjectsJava_HOME%\bin;%Path%
goto end
rem check UGO in Path
:checkPathUGO
set /a n+=1
for /f "delims=; tokens=%n% " %%a in ("%Path%") do (
if exist "%%a\com.supermap.data.jar" ( cd /d %%a\.. )
)
if %curr% NEQ %cd% (
set UGO_HOME=%cd%
goto end
) else if %n% LEQ 255 (
goto checkPathUGO )
:end
cd /d %BIN_DIR%
3、保存后启动Tomcat
现在再调用ObjectsJava中的方法,可以看到已经没有任何Wrapj.dll的问题了。