Bridge.Init() error

1,999 views
Skip to first unread message

David Anderson

unread,
Mar 5, 2012, 5:55:49 PM3/5/12
to jni4net, ande...@one.net
Hi,
I am getting an error when calling Bridge.Init from Java. Here is the
error message:
17:36:04,622 ERROR [STDERR] java.lang.IllegalArgumentException: URI is
not hierarchical
17:36:04,622 ERROR [STDERR] at java.io.File.<init>(File.java:335)
17:36:04,622 ERROR [STDERR] at
net.sf.jni4net.CLRLoader.findDefaultDll(CLRLoader.java:65)
17:36:04,622 ERROR [STDERR] at net.sf.jni4net.Bridge.init(Bridge.java:
42)
17:36:04,622 ERROR [STDERR] at
bcc.pages.documentManagement.DMTemplateLoader.doAction(DMTemplateLoader.java:
6209)
17:36:04,622 ERROR [STDERR] at
bcc.lib.BaseDoServlet.doServletFunction(BaseDoServlet.java:30)
17:36:04,622 ERROR [STDERR] at
bcc.lib.BaseBccServlet.doPost(BaseBccServlet.java:102)
17:36:04,637 ERROR [STDERR] at
bcc.lib.BaseBccServlet.doGet(BaseBccServlet.java:54)
17:36:04,637 ERROR [STDERR] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
17:36:04,637 ERROR [STDERR] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
17:36:04,637 ERROR [STDERR] at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:
96)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
235)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
235)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
191)
17:36:04,637 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:
190)
17:36:04,637 ERROR [STDERR] at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
92)
17:36:04,637 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:
126)
17:36:04,637 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:
70)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
127)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
17:36:04,637 ERROR [STDERR] at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:
158)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
17:36:04,637 ERROR [STDERR] at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
330)
17:36:04,637 ERROR [STDERR] at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
829)
17:36:04,637 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:598)
17:36:04,637 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint
$Worker.run(JIoEndpoint.java:447)
17:36:04,637 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)

When I specify a DLL during init:
Bridge.setVerbose(true);
Bridge.setDebug(true);

//Bridge.init();
Bridge.init(new File("C:\\Apps\\JBoss\\jboss-5.1.0.GA\\client\
\jni4net.n.w64.v20-0.8.6.0.dll"));

I get the following error:
loading core from C:/WINDOWS/assembly/GAC_MSIL/
jni4net.n-0.8.6.0/0.8.6.0__134a23405600bab4/jni4net.n-0.8.6.0.dll
loading jni4net.n-0.8.6.0, Version=0.8.6.0, Culture=neutral,
PublicKeyToken=134a23405600bab4 from C:\WINDOWS\assembly\GAC_MSIL
\jni4net.n-0.8.6.0\0.8.6.0__134a23405600bab4\jni4net.n-0.8.6.0.dll
Can't bind bridge:The type initializer for
'net.sf.jni4net.utils.Registry' threw an exception.
Can't bind bridge:System.TypeInitializationException: The type
initializer for 'net.sf.jni4net.utils.Registry' threw an exception. ---
> net.sf.jni4net.jni.JNIException: Can't find native
methodLoadAndRegisterAssemblyFromClassLoader()(Ljava/io/File;Ljava/
lang/ClassLoader;)V in class class net.sf.jni4net.Bridge
at net.sf.jni4net.utils.Registry.RegisterNative(MethodInfo
initializer, JNIEnv env, Class jvmProxy, Class jvmInterface)
at net.sf.jni4net.utils.Registry.BindJvm(RegistryRecord record,
JNIEnv env, ClassLoader classLoader)
at net.sf.jni4net.utils.Registry.RegisterType(Type type, Boolean
bindJVM, JNIEnv env, ClassLoader classLoader)
at net.sf.jni4net.utils.Registry.RegisterType(Type type, Boolean
bindJVM, JNIEnv env)
at net.sf.jni4net.utils.Registry..cctor()
--- End of inner exception stack trace ---
at net.sf.jni4net.utils.Registry.RegisterAssembly(Assembly
assembly, Boolean bindJVM, ClassLoader classLoader)
at net.sf.jni4net.Bridge.RegisterAssembly(Assembly assembly,
ClassLoader classLoader)
at net.sf.jni4net.Bridge.RegisterAssembly(Assembly assembly)
at net.sf.jni4net.Bridge.BindCore(JNIEnv env, BridgeSetup newSetup)
at net.sf.jni4net.Bridge.initDotNetImpl(IntPtr envi, IntPtr clazz)
17:53:40,754 ERROR [STDERR] Can't initialize jni4net BridgeT
17:53:54,720 ERROR [STDERR] net.sf.jni4net.inj.INJException: Can't
initialize jni4net Bridge
17:53:54,720 ERROR [STDERR] at
net.sf.jni4net.CLRLoader.init(CLRLoader.java:56)
17:53:54,720 ERROR [STDERR] at net.sf.jni4net.Bridge.init(Bridge.java:
46)
17:53:54,720 ERROR [STDERR] at
bcc.pages.documentManagement.DMTemplateLoader.doAction(DMTemplateLoader.java:
6210)
17:53:54,720 ERROR [STDERR] at
bcc.lib.BaseDoServlet.doServletFunction(BaseDoServlet.java:30)
17:53:54,720 ERROR [STDERR] at
bcc.lib.BaseBccServlet.doPost(BaseBccServlet.java:102)
17:53:54,720 ERROR [STDERR] at
bcc.lib.BaseBccServlet.doGet(BaseBccServlet.java:54)
17:53:54,736 ERROR [STDERR] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
17:53:54,736 ERROR [STDERR] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
17:53:54,736 ERROR [STDERR] at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:
96)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
235)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
235)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
191)
17:53:54,736 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:
190)
17:53:54,736 ERROR [STDERR] at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
92)
17:53:54,736 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:
126)
17:53:54,736 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:
70)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
127)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
17:53:54,736 ERROR [STDERR] at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:
158)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
17:53:54,736 ERROR [STDERR] at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
330)
17:53:54,736 ERROR [STDERR] at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
829)
17:53:54,736 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:598)
17:53:54,736 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint
$Worker.run(JIoEndpoint.java:447)
17:53:54,736 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
17:53:54,736 ERROR [STDERR] Caused by:
net.sf.jni4net.inj.INJException: T
17:53:54,736 ERROR [STDERR] at
net.sf.jni4net.Bridge.initDotNet(Native Method)
17:53:54,736 ERROR [STDERR] at
net.sf.jni4net.CLRLoader.init(CLRLoader.java:48)
17:53:54,736 ERROR [STDERR] ... 27 more


My environment:
- JNI4Net 0.8.6.0
- Windows XP 64-bit
- jdk1.5.0_22
- .Net 4
- Visual Studio 2010
- JARs and DLLs are all in C:\\Apps\\JBoss\\jboss-5.1.0.GA\\client

Does anyone have any ideas? I have gotten all of this to work
together a year ago on several other matchines, but now need to
upgrade the libraries and can't get past the Bridge.Init(). I can get
it to work in my test environmnent outside of JBoss.

Any help would be appreciated.
David.

Pavel Šavara

unread,
Mar 6, 2012, 4:01:42 AM3/6/12
to jni...@googlegroups.com
" URI is not hierarchical " -> that doesn't ring any bell

Here you are loading CLR version 2.0 but you said you want CLR 4.0
Bridge.init(new File("C:\\Apps\\JBoss\\jboss-5.1.0.GA\\client\\jni4net.n.w64.v20-0.8.6.0.dll"));
Further, it seems you are loading assemblies from GAC.
That should be OK, I believe.

But you have some problem with JVM class.
Can't find native method LoadAndRegisterAssemblyFromClassLoader()(Ljava/io/File;Ljava/lang/ClassLoader;)V in class net.sf.jni4net.Bridge

Try to load the jni4net.*.jar to system classLoader.

Pavel


> net.sf.jni4net.jni.JNIException: Can't find native
method LoadAndRegisterAssemblyFromClassLoader()(Ljava/io/File;Ljava/
David.

--
You received this message because you are subscribed to jni...@googlegroups.com
http://groups.google.com/group/jni4net?hl=en-GB?hl=en-GB
http://jni4net.sf.net/

David Anderson

unread,
Mar 6, 2012, 11:18:59 AM3/6/12
to jni4net
Pavel,

Thank you for you quick reply.

So the v20 means CLR 2.0 and v40 means CLR 4.0? Good to know. I
tried v40 and got the same error.

I have loaded the DLLs into the GAC with gacutil (though some failed
to load) because it was mentioned in the jni4net documentation (if I
remember correctly). The DLLs are also in the same folder as the
JARs.

Can you give more details about "Try to load the jni4net.*.jar to
system classLoader."? How do I do that? I've added
jni4net.j-0.8.6.0.jar to the libraries folder in the Java build path.
Are there other jni4net JAR files I should add? Should I specifically
load the JAR in my java code? I didn't need to do that before.

Again, I appreciate your help. I'm trying to upgrade a 3rd party .Net
DLL integrated into a JSP website using jni4net. It's been working
great for a year, but of course now the whole environment has changed
(CLR, OS, JDK, jni4net) and I don't know which part is causing the
problem.

Thanks,
David.

On Mar 6, 4:01 am, Pavel Šavara <pavel.sav...@gmail.com> wrote:
> " URI is not hierarchical " -> that doesn't ring any bell
>
> Here you are loading CLR version 2.0 but you said you want CLR 4.0
> Bridge.init(new File("C:\\Apps\\JBoss\\jboss-5.1.0.GA<http://jboss-5.1.0.ga/>
> \\client\\jni4net.n.w64.v20-0.8.6.0.dll"));
> Further, it seems you are loading assemblies from GAC.
> That should be OK, I believe.
>
> But you have some problem with JVM class.
> Can't find native method
> > bcc.pages.documentManagement.DMTemplateLoader.doAction(DMTemplateLoader.jav­a:
> > 6210)
> > 17:53:54,720 ERROR [STDERR]     at
> > bcc.lib.BaseDoServlet.doServletFunction(BaseDoServlet.java:30)
> > 17:53:54,720 ERROR [STDERR]     at
> > bcc.lib.BaseBccServlet.doPost(BaseBccServlet.java:102)
> > 17:53:54,720 ERROR [STDERR]     at
> > bcc.lib.BaseBccServlet.doGet(BaseBccServlet.java:54)
> > 17:53:54,736 ERROR [STDERR]     at
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> > 17:53:54,736 ERROR [STDERR]     at
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio­nFilterChain.java:
> > 290)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC­hain.java:
> > 206)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.j­ava:
> > 96)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio­nFilterChain.java:
> > 235)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC­hain.java:
> > 206)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j­ava:
> > 235)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j­ava:
> > 191)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoc­iationValve.java:
> > 190)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java­:
> > 92)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(Sec­urityContextEstablishmentValve.java:
> > 126)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(Secu­rityContextEstablishmentValve.java:
> > 70)
> > 17:53:54,736 ERROR [STDERR]     at
> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
> > 127)
> > 17:53:54,736 ERROR [STDERR]     at
> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
> > 102)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnect­ionValve.java:
> > 158)
> > 17:53:54,736 ERROR [STDERR]     at
>
> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav­a:
> >http://jni4net.sf.net/- Hide quoted text -
>
> - Show quoted text -

Pavel Šavara

unread,
Mar 6, 2012, 11:29:44 AM3/6/12
to jni...@googlegroups.com
On Tue, Mar 6, 2012 at 5:18 PM, David Anderson <fren...@gmail.com> wrote:
Pavel,

Thank you for you quick reply.

So the v20 means CLR 2.0 and v40 means CLR 4.0?  
Yes
 
Good to know.  I
tried v40 and got the same error.

I have loaded the DLLs into the GAC with gacutil (though some failed
to load) because it was mentioned in the jni4net documentation (if I
remember correctly).  The DLLs are also in the same folder as the
JARs.

Try to uninstall it from GAC and use it only from the directory. Just in case .... but not likely.
 
Can you give more details about "Try to load the jni4net.*.jar to
system classLoader."?  How do I do that?  I've added
jni4net.j-0.8.6.0.jar to the libraries folder in the Java build path.
Are there other jni4net JAR files I should add?  Should I specifically
load the JAR in my java code?  I didn't need to do that before.


You mentioned JBoss. I'm guessing it may be loading your classes into his own classLoaders.
How you change that, i don't know for JBoss.
general Java does that via command line.

David Anderson

unread,
Mar 8, 2012, 12:59:10 PM3/8/12
to jni4net
Update...
I was finally able to get around the Bridge.Init() URI error by
loading a specific jni4net DLL, namely:
Bridge.init(new File("C:\\apps\\MyApp\
\jni4net.n.w64.v40-0.8.6.0.dll"));
I never had to do this before.
Also, I noticed that I had conflicting JAR versions loaded (8.0.0 and
8.6.0) in the Java Build Path libraries.
I was able to fix that so only one version of jni4net was referenced.
The bottom line is that I do have a working system again.

Hopefully my update may help someone else in the future.
Thanks for your help and this great product!


On Mar 6, 11:29 am, Pavel Šavara <pavel.sav...@gmail.com> wrote:
> > > >http://jni4net.sf.net/-Hide quoted text -

Pavel Šavara

unread,
Mar 8, 2012, 3:35:27 PM3/8/12
to jni...@googlegroups.com
Thanks for update!

mellooe

unread,
Mar 14, 2014, 4:57:46 AM3/14/14
to jni...@googlegroups.com
The solution also helps in my case - Thanks for that.
Reply all
Reply to author
Forward
0 new messages