vFabric tc服务器在启动执行“System.loadLibrary("...")
”的Spring bean时无法加载我的JNI库。实际上,我需要从vFabric tcServer版本(STS)Spring Tools Suite中部署的Spring bean中执行一些JNI共享库。
虽然我按照“Customizing the environment or JVM options for vFabric tc Server (2030216)”中的建议操作,但错误仍然存在:“nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [my.JniServiceFactory]: Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: no myJNIsharedLib in java.library.path
”
我进一步发现了tc服务器实例wrapper.log
目录中.../bin/winx86_64
文件中的错误:Unable to open configuration file. C:\java\SpringTools\vfabric-tc-server-developer-2.9.6.RELEASE\base-instance\bin\winx86_64\wrapper.conf
并且在命令行执行包装器时发现错误:wrapper -q ..\..\conf\wrapper.conf
,产生wrapper | OpenSCManager failed - Access is denied. (0x5)
,这表明存在UAC问题。所以我将我的Windows帐户提升为管理员,甚至关闭了UAC ...这解决了wrapper.exe错误,但在tc服务器中启动我的应用程序时没有解决UnsatisfiedLinkError。
我还在tc服务器实例目录下发现了一个'setenv.bat
'文件,其中包含邀请您定义它的行'set JAVA_LIBRARY_PATH=
',但没有效果。
我还尝试在我的系统属性下设置一个全局环境变量JAVA_LIBRARY_PATH,因此在启动Spring Tools然后启动tc服务器时可用......没办法。
答案 0 :(得分:0)
实际上,我发现的解决方案在Eclipse RUN配置下保存。
在Eclipse菜单中运行>运行配置...> VMware vFabric开发人员版>参数选项卡> VM参数:在长列表中添加额外的-Djava.library.path = \ java \ git \ MySharedLibRepo并重新启动tc Server ...这解决了这个问题。
还要确保在MS-Windows下,System.loadLibrary("...")
加载的目标JNI本机库具有.dll本机库的确切基本名称(因此没有.dll扩展名)。
确实不需要管理员权限。一个普通的Windows用户帐户很好。