This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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>
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.
resource-ref is for things like queue connection factories or data sources. It has nothing to do with referencing EJBs, and you would never have any need to know about stub implementations in the deployment descriptors.
Reid - SCJP2 (April 2002)
Anibal Gimenez Canicoba
Joined: Oct 31, 2004
You right, the right tag should be <res-type>com.mycompany.MyBean</res-type>, but I don't want to publish an EJB, I want to work with RMI-iiop, I created a simple bean whith its stub and skeleton(rmic) and I would like to let it available like a resource in the simple RMI registry but in an app. server. I heard or read in some place that this is possible(publish as a resource).
Reid M. Pinchback
Joined: Jan 25, 2002
BEA has a lot of documentation on using RMI-IIOP with Weblogic; you may want to start there and see if you could back-port any of the info to JBoss. I'd have to say this sounds amazingly painful, since all EJB is doing is automatically creating for you the very things that you are going to need to create manually. Particularly if the webapp and the ejb layer are deployed in the same server, this is rather bizarre.
I'd still be surprised if the specific deployment descriptor tags you are using turn out to be the correct ones; I'm inclined to think that a square peg is getting shoved into a round hole. You may want to consider resource-env-ref as another option. resource-ref is really intended for JCA resource adapters or things that behave very similarly, like data sources. If you wouldn't resolve a bean binding via resource-ref, I'm surprised if you'd resolve its RMI equivalent that way.
You'll probably need to poke around in the jmx-console app to see where JBoss is binding things. Trying to use an ENC to resolve the binding might be adding to your problem. Going through the global JNDI tree may make more sense for you. [ February 03, 2006: Message edited by: Reid M. Pinchback ]