[英]Use shared library(.so) in spring web application deployed on glassfish web server
I am using System.loadLib() in a spring web application deployed on glassfish to load a .so (jni shared library) in my application...But when System.loadLibrary executes the server stop suddenly without any exception in server log! 我正在在Glassfish上部署的Spring Web应用程序中使用System.loadLib()在应用程序中加载.so(jni共享库)...但是,当System.loadLibrary执行服务器时,服务器日志突然停止,没有任何异常!
what is the problem ? 问题是什么 ? my code:
我的代码:
@Controller
@RequestMapping(value = "/getdata", method = RequestMethod.POST)
public class temperatureController {
@RequestMapping(value = "/temp" , method = RequestMethod.GET)
public @ResponseBody
float getTemperature(){
System.err.print("beforeeeeeeeeeeeN");
NativeClass n = new NativeClass();
System.err.print("beforeeeeeeeeeeeLoadLib");
try {
System.loadLibrary("NativeClass");
System.err.print("LoadedintempClass");
}
catch (Throwable e){
System.err.print("not loaded in temp class");
e.printStackTrace();
}
System.err.print("afteeeeeeeerLoadLib");
float temp = n.getTemperature(); // invoke the native method
System.err.print("tttttttttt");
System.err.print(temp);
return temp ;
}
server log : 服务器日志:
[2016-05-30T19:40:36.364+0000] [glassfish 4.1] [SEVERE] [] [] [tid: _ThreadID=27 _ThreadName=Thread-9] [timeMillis: 1464637236364] [levelValue: 1000] [[
beforeeeeeeeeeeeN]]
[2016-05-30T19:40:36.391+0000] [glassfish 4.1] [SEVERE] [] [] [tid: _ThreadID=27 _ThreadName=Thread-9] [timeMillis: 1464637236391] [levelValue: 1000] [[
beforeeeeeeeeeeeLoadLib]]
It is most probably a segmentation fault caused by the library and it brings down whole JVM. 这很可能是由库引起的分段错误,它导致整个JVM崩溃。 Try running GlasssFish from command line using
bin/asadmin start-domain --verbose
to keep running in the same console window. 尝试使用
bin/asadmin start-domain --verbose
从命令行运行GlasssFish,以保持在同一控制台窗口中运行。 You may be able to see SEGMENTATION FAULT
in the console if it's the case. 在这种情况下,您可能会在控制台中看到
SEGMENTATION FAULT
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.