aspose file tools*
The moose likes JBoss/WildFly and the fly likes Troubles when try to lookup java:comp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Troubles when try to lookup java:comp" Watch "Troubles when try to lookup java:comp" New topic
Author

Troubles when try to lookup java:comp

Anibal Gimenez Canicoba
Greenhorn

Joined: Oct 31, 2004
Posts: 19
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
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
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
Greenhorn

Joined: Oct 31, 2004
Posts: 19
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).

Any idea?


Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
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 ]
Wiley Snyder
Greenhorn

Joined: Oct 26, 2005
Posts: 23
<ejb-ref>
<ejb-ref-name>ejb/[myEjb]</ejb-ref-name>
<jndi-name>ejb/[package]/[myEjb]</jndi-name>
</ejb-ref>
Wiley Snyder
Greenhorn

Joined: Oct 26, 2005
Posts: 23
what version are you using ???

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Troubles when try to lookup java:comp