Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

NamingException: java:comp/env/LoginBean not found

 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any body tell how to deploy a session bean on Weblogic 7.0???
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Grand Puba,
I'll try this and post the reply here.
Thanks for your reply.
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic