aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes problem doing a lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "problem doing a lookup" Watch "problem doing a lookup" New topic
Author

problem doing a lookup

meka toka
Ranch Hand

Joined: Dec 11, 2002
Posts: 75
Hi,
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
ver/default/deploy/Meka.ear
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
ntext=2,context=/MekaWeb
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:
\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Jetty_0_0_0_0_8080__MekaWeb\webapp
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/
default/tmp/deploy/server/default/deploy/Meka.ear/58.Meka.ear-contents/MekaWeb.w
ar to /MekaWeb
14:30:47,203 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.4/server/
default/deploy/Meka.ear
14:30:47,218 INFO [URLDeploymentScanner] Started
14:30:47,218 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.4/server/
default/conf/jboss-service.xml
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.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put("java.naming.factory.url.pkgs",
"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(NamingServer.java:495)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:456)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:440)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at Client.<init>(Client.java:39)
at Client.main(Client.java:87)

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


Thanks<br />MekaToka<br />SCJP 1.4
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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
Simon
meka toka
Ranch Hand

Joined: Dec 11, 2002
Posts: 75
Hi,
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem doing a lookup
 
Similar Threads
mssqlds not bound and throws NameNotFoundException
Message driven beans are not bound into remote jndi
EJB already registered exception
NameNotFoundException - but the jndi bound
Simple EJB3 session beans not deploying in JBOSS6