【问题标题】:Error calling jni4net on a webService, URI scheme is not "file"在 webService 上调用 jni4net 时出错,URI 方案不是“文件”
【发布时间】:2021-08-08 03:13:00
【问题描述】:

我正在使用 jni4net,我正在读取 java 应用程序中的 .NET dll,当我直接在 main 方法上运行时它可以工作。下面是一个例子:

public static void main( String[] args ) throws IOException {       
    
    Bridge.setVerbose(true);
    Bridge.init();
    File dllFile2 = new File("Cripto.j4n.dll");
    Bridge.LoadAndRegisterAssemblyFrom(dllFile2);
    ...
    ...
  }

但是,当我尝试从下面的以下 Web 服务运行时

@GET
@Path("/conect")
public String conect() throws IOException { 
    
    Bridge.setVerbose(true);
    Bridge.init(); //the error is triggered at this point
    ...
    ...

}

发布以下错误:

Caused by: java.lang.IllegalArgumentException: URI scheme is not "file"
    

我已经尝试指出 dll Cripto.j4n.dll 的路径指示绝对路径,但它不起作用,在我的尝试示例下方:

Bridge.init(new File("C:\\apps\\MyApp\\Cripto.j4n.dll"));
Bridge.init(new File("Cripto.j4n.dll")); //also tried this way

无论如何,我需要从 webService 上的 .dll 进行调用,服务器是 Wildfly 9,我该怎么做?有什么提示吗?

【问题讨论】:

    标签: java .net web-services jni4net proxygen


    【解决方案1】:

    错误表明它需要file:<full path here> 格式的路径,请在此处查看答案:Unable to call dll from Oracle 和此处:URI scheme is not "file"

    【讨论】:

    • 我尝试按照这些示例中所示的方式进行操作,但没有成功:( ...但我有一点怀疑,因为当我使用“public static main”方法和我调用 Bridge.init () 它可以工作,当我调用运行在 wildfly 上的系统并从 webService 调用时,它可以工作吗?
    【解决方案2】:

    我找到了解决办法。

    我直接指向 .dll 文件,此外,我指向错误的 .dll,他正在寻找“jni4net.n-0.8.5.0.dll”而不是“Cripto.j4n.dll” (这是我创建的文件),所以解决方案是指出“jni4net.n-0.8.5.0.dll”所在的文件夹是这样的:

    Bridge.init( new java.io.File("C:\apps\MyApp")); 
    

    我没有报告该文件,而是它所在的文件夹“jni4net.n-0.8.5.0.dll”

    【讨论】:

      猜你喜欢
      • 2011-02-20
      • 2013-07-30
      • 2013-01-28
      • 1970-01-01
      • 2012-06-14
      • 1970-01-01
      • 2012-02-20
      • 2015-12-29
      • 2014-07-31
      相关资源
      最近更新 更多