I created a new resource on my
jboss and I was trying to get the reference through JNDI, but I got some error when tryied do that.
1_ I declared on jboss-web.xml of my app this:
<?xml version="1.0" encoding="UTF-8" ?>
<jboss-web>
<resource-ref>
<res-ref-name>bean/MyBeanFactory</res-ref-name>
<res-type>com.mycompany.MyBean_Stub</res-type>
<jndi-name>
java:bean/MyBeanFactory</jndi-name>
</resource-ref>
</jboss-web>
2_ the web.xml file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app>
<display-name>Bean
Test</display-name>
<description>Just a bean test</description>
<resource-ref>
<res-ref-name>bean/MyBeanFactory</res-ref-name>
<res-type>com.mycompany.MyBean_Stub</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
3_ In the client app I did this:
String sInitialContextFactory = "org.jnp.interfaces.NamingContextFactory";
String sProviderUrl = "jnp://localhost:1099";
String sInterface = "org.jboss.naming
rg.jnp.interfaces";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, sInitialContextFactory);
env.put(Context.PROVIDER_URL, sProviderUrl);
env.put(Context.URL_PKG_PREFIXES, sInterface);
Context initialContext = new InitialContext(env);
Object obj = initialContext.lookup("/bean/MyBeanFactory");
---------------------------------------------------------------
I get the following exception.
Exception in
thread "main" javax.naming.NameNotFoundException: bean 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.GeneratedMethodAccessor124.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
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(Unknown Source)
at com.mycompany.BeanClient.main(BeanClient.java:41)
------------**************----------------
Tired of try that, I did other thing, I made a lookup to "java:comp" and I got the same exception "comp not bound"
Any Idea? I think is something related with the Naming context.
Is this the right step to registry a resource?
Anibal