Error calling jni4net on a webService, URI scheme is not "file"

148 Views Asked by At

I'm using jni4net, I'm reading a .NET dll in a java application, and it works when I run direct on the main method. Below is an example:

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

However, when I try to run from the following webservice below

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

}

The following error is posted:

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

I've already tried to point the path of dll Cripto.j4n.dll indicating the absolute path but it did not work, below the example of my attempt:

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

Anyway, I need to make the calls from .dll on webService, the server is a wildfly 9, how do I? any hint?

2

There are 2 best solutions below

0
On

I was able to find the solution.

I was pointing directly to the .dll file, and besides, I pointed to the .dll wrong, he was looking for the "jni4net.n-0.8.5.0.dll" and not the "Cripto.j4n.dll" (which was the file I created), so the solution was to point out the folder where the "jni4net.n-0.8.5.0.dll" was like this:

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

I DID NOT REPORT THE FILE , BUT THE FOLDER WHERE IT WAS "jni4net.n-0.8.5.0.dll"

1
On

The error is indicating that it expects a path in the format file:<full path here>, please see the answers here: Unable to call dll from Oracle and here: URI scheme is not "file"