You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by joi <jo...@maskina.com> on 2001/07/04 18:19:59 UTC
Lookup ejb's in action classes
I have a problem performin lookup on my ejb's in struts action classes.
I always get NameNotFoundException. I'm pretty sure that my ejb-jar.xml
and web.xml are correct. Is this a common problem accessing the Context
through the struts action classes?
I'm using orion 1.5.2 app. server.
Code from my action class..
..
Context ctx = new InitialContext();
Object homeObject = ctx.lookup("java:comp/env/ejbUserManagement");
//throws NameNotFoundException here.
home = (UserManagementHome)PortableRemoteObject.narrow(homeObject,
UserManagementHome.class);
..
As I said before I am pretty sure that my ejb-jar.xml and web.xml are
correct so what could be causing this? I've tried almost everything I
can think of..
Any ideas..
Re: Lookup ejb's in action classes
Posted by Pham Thanh Quan <qu...@sdcgrp.com>.
MessageYou must have the following in your web.xml file
<ejb-ref>
<ejb-ref-name>ejbUserManagement</ejb-ref-name>
<ejb-ref-type>Entity(or Session)</ejb-ref-type>
<home>home bean here (e.g. project.package.UserManagementHome)</home>
<remote>remote here (e.g. project.package.UserManagement)</remote>
</ejb-ref>
after that, you must also have the following in the server-specific config file (e.g. in weblogic, it is weblogic.xml)
<ejb-reference-description>
<ejb-ref-name>ejbUserManagement</ejb-ref-name>
<jndi-name>jndi name of your bean</jndi-name>
</ejb-reference-description>
Or for more simple, you should use this instead :
Object homeObject = ctx.lookup("JNDI name of your bean here");
home = (UserManagementHome)PortableRemoteObject.narrow(homeObject, UserManagementHome.class);
----- Original Message -----
From: Jan Heise
To: johann@maskina.com
Cc: struts
Sent: Thursday, July 05, 2001 12:10 AM
Subject: AW: Lookup ejb's in action classes
hi,
i use the jndi-browser that comes with sun's jndi-examples once in a while
to check if my context contains what i expect to. on my last project with
orion (but i did not use struts) i also set
java.naming.factory.initial=com.evermind.server.ApplicationClientInitialContextFactory
java.naming.provider.url=ormi://localhost/appname
java.naming.security.principal=user here
java.naming.security.credentials=password here
even though i call this from inside my jsps and it should possibly be not necessary - but it works.
hope that helps.
jan
--
Jan Heise / Tel: +49-170-4803237 / E-Mail: jan@janheise.de
-----Ursprüngliche Nachricht-----
Von: joi [mailto:johann@maskina.com]
Gesendet: Mittwoch, 4. Juli 2001 18:20
An: struts-user@jakarta.apache.org
Betreff: Lookup ejb's in action classes
I have a problem performin lookup on my ejb's in struts action classes. I always get NameNotFoundException. I'm pretty sure that my ejb-jar.xml and web.xml are correct. Is this a common problem accessing the Context through the struts action classes?
I'm using orion 1.5.2 app. server.
Code from my action class..
..
Context ctx = new InitialContext();
Object homeObject = ctx.lookup("java:comp/env/ejbUserManagement"); //throws NameNotFoundException here.
home = (UserManagementHome)PortableRemoteObject.narrow(homeObject, UserManagementHome.class);
..
As I said before I am pretty sure that my ejb-jar.xml and web.xml are correct so what could be causing this? I've tried almost everything I can think of..
Any ideas..
AW: Lookup ejb's in action classes
Posted by Jan Heise <he...@pnpconsult.com>.
Messagehi,
i use the jndi-browser that comes with sun's jndi-examples once in a while
to check if my context contains what i expect to. on my last project with
orion (but i did not use struts) i also set
java.naming.factory.initial=com.evermind.server.ApplicationClientInitialCont
extFactory
java.naming.provider.url=ormi://localhost/appname
java.naming.security.principal=user here
java.naming.security.credentials=password here
even though i call this from inside my jsps and it should possibly be not
necessary - but it works.
hope that helps.
jan
--
Jan Heise / Tel: +49-170-4803237 / E-Mail: jan@janheise.de
-----Ursprungliche Nachricht-----
Von: joi [mailto:johann@maskina.com]
Gesendet: Mittwoch, 4. Juli 2001 18:20
An: struts-user@jakarta.apache.org
Betreff: Lookup ejb's in action classes
I have a problem performin lookup on my ejb's in struts action classes. I
always get NameNotFoundException. I'm pretty sure that my ejb-jar.xml and
web.xml are correct. Is this a common problem accessing the Context through
the struts action classes?
I'm using orion 1.5.2 app. server.
Code from my action class..
..
Context ctx = new InitialContext();
Object homeObject = ctx.lookup("java:comp/env/ejbUserManagement");
//throws NameNotFoundException here.
home = (UserManagementHome)PortableRemoteObject.narrow(homeObject,
UserManagementHome.class);
..
As I said before I am pretty sure that my ejb-jar.xml and web.xml are
correct so what could be causing this? I've tried almost everything I can
think of..
Any ideas..