【问题标题】:Use shared library(.so) in spring web application deployed on glassfish web server在 glassfish Web 服务器上部署的 Spring Web 应用程序中使用共享库(.so)
【发布时间】:2016-09-01 06:48:15
【问题描述】:

我在 glassfish 上部署的 Spring Web 应用程序中使用 System.loadLib() 来在我的应用程序中加载 .so(jni 共享库)...但是当 System.loadLibrary 执行服务器时,服务器突然停止,服务器没有任何异常日志!

有什么问题? 我的代码:

@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 ;
     }

服务器日志:

 [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]]

【问题讨论】:

    标签: java spring spring-mvc java-native-interface glassfish


    【解决方案1】:

    这很可能是由库引起的分段错误,它导致整个 JVM 崩溃。尝试使用bin/asadmin start-domain --verbose 从命令行运行 GlasssFish,以继续在同一控制台窗口中运行。如果是这种情况,您可能会在控制台中看到SEGMENTATION FAULT

    【讨论】:

      猜你喜欢
      • 2012-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      • 2020-09-17
      • 1970-01-01
      • 2012-06-23
      相关资源
      最近更新 更多