2

我用 c++ (MediumDll.dll) 创建了一个 dll 库并将它放在一个文件夹 (C:\Program Files (x86)\Java\jre7\bin) 中。

我用 Eclipse 和 Call dll library 创建了一个 Java 项目。在 Java Application 上运行,结果成功。我可以得到数据。

但是我将相同的代码复制到 Web 服务出现错误...

请帮助我,谢谢大家

文件目录

网络

  • 源代码
    • com.body.rsservice
      • CallThirdPartyClass.java
      • CallThirdParty.java
  • 网页内容

CallThirdPartyClass.java

package com.body.rsservice;

public class CallThirdPartyClass {

    public native int[] CallThirdPartyDll(double[]    arg_DoubleArray,
            int         arg_SizeofArray,
            boolean     arg_print);

    public CallThirdPartyClass() 
    {
        System.loadLibrary("MediumDll");
    }

}

CallThirdParty.java

package com.body.rsservice;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.io.*;
import org.apache.cxf.annotations.GZIP;


@Path("/test")
public class CallThirdParty {

    @GET
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public double[] GetCallThirdParty(){
        double doubleArray[] = {1.1, 2.5, 5,2};

        CallThirdPartyClass callThirdParty = new CallThirdPartyClass();
        callThirdParty.CallThirdPartyDll(doubleArray, 3, true);
        System.out.println("OK");

        int cutOffArray[] = callThirdParty.CallThirdPartyDll(doubleArray, 3, true);

        for (int i = 0; i < cutOffArray.length; ++i)
            System.out.println(cutOffArray[i]);
        return doubleArray;
    }

}

错误信息

HTTP Status 500 - org.apache.cxf.interceptor.Fault: com.body.rsservice.CallThirdPartyClass.CallThirdPartyDll([DIZ)[I

type Exception report

message org.apache.cxf.interceptor.Fault: com.body.rsservice.CallThirdPartyClass.CallThirdPartyDll([DIZ)[I

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: com.body.rsservice.CallThirdPartyClass.CallThirdPartyDll([DIZ)[I
    org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:117)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:331)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
root cause

org.apache.cxf.interceptor.Fault: com.body.rsservice.CallThirdPartyClass.CallThirdPartyDll([DIZ)[I
    org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
root cause

java.lang.UnsatisfiedLinkError: com.body.rsservice.CallThirdPartyClass.CallThirdPartyDll([DIZ)[I
    com.body.rsservice.CallThirdPartyClass.CallThirdPartyDll(Native Method)
    com.body.rsservice.CallThirdParty.GetCallThirdParty(CallThirdParty.java:23)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.39 logs.

Apache Tomcat/7.0.39
4

0 回答 0