The-gtm, thank you for the tip.
I changed the name as you said, but now I get a NameNotFoundException before the NullPointerException, when I try to lookup the factory in the initial context. I've read somewhere that all names starting with "java:/" are local to the VM and therefore cannot be seen by other applications outside the server. But my client application runs on the same machine and on the same instance of the JBoss application server as the Hibernate service!! I can see the name bound to JNDI in the JMX console under Java namespace, like this:
Code:
+- hibernate (class: org.jnp.interfaces.NamingContext)
| +- ExampleSessionFactory (class: org.hibernate.impl.SessionFactoryImpl)
So I don't understand why the application code throws this exceptioin:
Code:
Initial SessionFactory creation failed.javax.naming.NameNotFoundException: hibernate not bound
javax.naming.NameNotFoundException: hibernate not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at au.com.tusc.client.TestHibernate.initialize(TestHibernate.java:45)
at au.com.tusc.client.TestHibernate.testEventEx(TestHibernate.java:61)
at au.com.tusc.client.TestHibernate.main(TestHibernate.java:88)
If I choose to bind the session factory to a global name, without "java:/" in front of it, I get the NPE as explained in my first post.
Could anyone help with some advice? Thanks a lot in advance.
Horia.