Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem doing a lookup  RSS feed

meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used pramati studip 3.0 and JBoss 3.0.4
PROBLEM: i am not able to do a llok up on the beans running on the server.
SITUATION:: I have written a session bean which communicates with an entity bean. I deployed them on JBoss 3.0.4 and they were succesfully deployed.
Here is the server console
14:30:45,015 INFO [EARDeployer] Init J2EE application: file:/C:/jboss-3.0.4/ser
14:30:45,171 INFO [EjbModule] Creating
14:30:45,171 INFO [EjbModule] Deploying Entity
14:30:45,328 INFO [EjbModule] Deploying Session
14:30:45,390 INFO [EjbModule] Created
14:30:45,390 INFO [EjbModule] Starting
14:30:46,765 INFO [Entity] Created table 'ENTITY' successfully.
14:30:46,781 INFO [EjbModule] Started
14:30:46,859 INFO [jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationCo
14:30:46,906 INFO [jbossweb] Extract jar:file:/C:/jboss-3.0.4/server/default/tm
p/deploy/server/default/deploy/Meka.ear/58.Meka.ear-contents/MekaWeb.war!/ to C:
14:30:47,187 INFO [jbossweb] Started WebApplicationContext[/MekaWeb,MekaWeb]
14:30:47,203 INFO [jbossweb] successfully deployed file:/C:/jboss-3.0.4/server/
ar to /MekaWeb
14:30:47,203 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.4/server/
14:30:47,218 INFO [URLDeploymentScanner] Started
14:30:47,218 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.4/server/
14:30:47,218 INFO [Server] JBoss (MX MicroKernel) [3.0.4 Date:200211021607] Sta
rted in 0m:18s:906ms
Now i have written a client which looks up the session bean as below

Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "localhost:1099");
"org.jboss.naming rg.jnp.interfaces");

try {

Context ctx = new InitialContext(env);

Session_LocalHome session_lh = (Session_LocalHome) ctx.lookup("java:comp/env/Session_LocalHome");
Session_Local session_local = session_lh.create();
I am getting the following error
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getObject(
at org.jnp.server.NamingServer.lookup(
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
at java.lang.reflect.Method.invoke(
at sun.rmi.server.UnicastServerRef.dispatch(
at sun.rmi.transport.Transport$
at Method)
at sun.rmi.transport.Transport.serviceCall(
at sun.rmi.transport.tcp.TCPTransport.handleMessages(
at sun.rmi.transport.tcp.TCPTransport$
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
at sun.rmi.transport.StreamRemoteCall.executeCall(
at sun.rmi.server.UnicastRef.invoke(
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(
at org.jnp.interfaces.NamingContext.lookup(
at javax.naming.InitialContext.lookup(
at Client.<init>(
at Client.main(

I have tried to look in the internet for a long time but could not get enough help. I have even looked a couple of books but i havent been able to get proper help.
And yeah i am trying to look up beans on LocalHome interfaces because client and beans are on same JVM (same machine).
Thank You
Meka Toka
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately you won't be able to lookup a reference to a local EJB from outside of the JVM, regardless of whether the client and server are on the same machine. You have a couple of options...
(1) You could make your session bean remote.
(2) You could write a web (servlet/JSP) client that runs in the same JVM.
Whichever you choose, you must also ensure that you are using the correct JNDI name (e.g. the one defined in the jboss.xml file).
Hope that helps
meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The earlier problem was because there was no name-to-object binding at location where i was doing a lookup. And also my client.jar was not properly done.
I resolved the javax.naming.NameNotFoundException.
Now i am doing a lookup on the remote interface of the session bean, but i am getting a javax.naming.CommunicationException.
From what i gathered on the net, alot of people have said it might be because client.jar is not included in the classpath.
But my client.jar is included in classpath.
What is that i am missing here ?
Thank You
Meka Toka
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!