服务器上的tomcat调用DLL报错,但是在本地的IDEA中运行没有问题

报错如下:

我的servlet代码如下:
package com.zhou.web;

import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
import com.zhou.DLL.CallDll;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(“/transferServlet2”)
public class TransferServlet2 extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    request.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=utf-8");

    //装载dll
    CallDll dlltext2 = (CallDll) Native.load("DLL-Cantilever(2)", CallDll.class);
    //上传文件路径
    String XuanPath = (String) this.getServletContext().getAttribute("xuanpath");

    //结果文件路径
    String XuanDownload = request.getSession().getServletContext().getRealPath("/WEB-INF/result2");
    String XuanDownloadPath = XuanDownload+"\\";

    int f = XuanPath.length();
    for(int i=0;i<f;i++)
    {
        XuanPath = XuanPath+ " ";
    }
    int e = XuanDownloadPath.length();
    for(int j=0;j<e;j++)
    {
        XuanDownloadPath = XuanDownloadPath+ " ";
    }

    IntByReference n1 = new IntByReference(XuanPath.length());
    IntByReference n2 = new IntByReference(XuanDownloadPath.length());

    dlltext2.DllCANTILEVERCAST(XuanPath,XuanDownloadPath,n1,n2);

    request.getRequestDispatcher("/uploadxuan.jsp").forward(request, response);

}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doGet(request, response);
}

}
我的dll已经放在了tomcat的bin目录下了,还是报错,希望大家给个提示吧!

讨论数量: 1

如果服务器是 Linux 环境,有没有考虑过 dll 文件的读取权限?

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!