Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NamingException: java:comp/env/LoginBean not found  RSS feed

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all i'm getting the follwoing exception .when i'm trying to access a bean from a standlone client.

NamingException: java:comp/env/LoginBean not found
But i'm able to access the same bean from a jsp deployed in the server.

Any one help me please.
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your jsp might be running in the same container as you bean. That's why it's able to find bean. Since the standalone client is outside the container, it needs the env variables for the container for lookup. For eg, if you are running the beans in a sun app server, you need to create your Context as :-

java.util.Hashtable env = new java.util.Hashtable();
env.putContext.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:3700");
Context initial = new InitialContext(env);
Object obj = (Object) initial.lookup("/ejb/LoginBean");

The env properties may vary depending on your app server

[ October 27, 2004: Message edited by: Giju George ]
[ October 27, 2004: Message edited by: Giju George ]
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Giju is right ...

for your standalone java client try this :

Object obj = (Object) initial.lookup("java:comp/env/ejb/LoginBean");
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
What is the reason for using this line particularly for EJB Client that is not in a container,


Cant I type cast like this directly ..


Then as you guys said i'm using the Hashtable & setting the relevant stuff , but i'm getting NamingException saying the Bean is not found.
The same client was working in weblogic, After the server is migrated to oracle10g i'm facing this exception.
 
Sreenath Reddy Putta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body tell how to deploy a session bean on Weblogic 7.0???
 
Grand Puba
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Cant I type cast like this directly ..
code: loginHome = (LoginHome)context.lookup("java:comp/env/LoginBean");


You can safely cast the LocalHome interface but only when you 're sure it's local interface. For remote interfaces, you will need to use PortableRemoteObject.narrow(homeObject). (That's because of the IIOP protocol used)


The same client was working in weblogic, After the server is migrated to oracle10g i'm facing this exception.

Oracle uses the special ORMI protocol (instead of RMI-IIOP) which is, in my opinion, the start of a lot of problems...
Anyway, the HashTable should look like:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "jazn.com/admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put(Context.PROVIDER_URL, "ormi://localhost:<port>/ejbsamples");

Hope this was helpfull...

Cheers
[ November 14, 2004: Message edited by: Grand Puba ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Grand Puba,
I'll try this and post the reply here.
Thanks for your reply.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!