I use an servlet calling an Local interface sessionBean,but the Exception tell me Naming not found , I think this reason is JNDI deploy.
I use the JBuilder platform ,weblogic server,but I dot know how to deploy the JNDI ,please tell me ,thanks.
this is the weblogic-ejb-jar.xml:
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>test1</ejb-name>
<jndi-name>test1</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
my servlet source:the getTest() method is a Local method
Context ctx = new InitialContext();
test1Home test1home = (test1Home) ctx.lookup("java:comp/env/ejb/test1");
String testok = test1home.create().getTest();
-
JNDI question? (4 messages)
- Posted by: jiang yh
- Posted on: July 02 2003 04:57 EDT
Threaded Messages (4)
- JNDI question? by Dave Segal on July 02 2003 08:11 EDT
- JNDI question? by Brian Chan on July 02 2003 09:23 EDT
- JNDI question? by Brian Tinnel on July 02 2003 10:18 EDT
- JNDI question? by Seshagiri Varanasi on July 03 2003 16:14 EDT
-
JNDI question?[ Go to top ]
- Posted by: Dave Segal
- Posted on: July 02 2003 08:11 EDT
- in response to jiang yh
You can only use the local interface between ejbs that are running in the same container. You can't use the local interface between servlets and ejbs. Try using the remote interface in your servlet and it should work.
Dave -
JNDI question?[ Go to top ]
- Posted by: Brian Chan
- Posted on: July 02 2003 09:23 EDT
- in response to jiang yh
If everything is deployed in an EAR file, you can use Local interfaces to access EJB from the servlet -
JNDI question?[ Go to top ]
- Posted by: Brian Tinnel
- Posted on: July 02 2003 10:18 EDT
- in response to jiang yh
In order for your lookup to work you will also need an <ejb-local-ref> in your web.xml for the servlet:
<ejb-local-ref>
<ejb-ref-name>ejb/test1</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home> classname of local home interface </local-home>
<local> classname of local interface </local>
</ejb-local-ref> -
JNDI question?[ Go to top ]
- Posted by: Seshagiri Varanasi
- Posted on: July 03 2003 16:14 EDT
- in response to jiang yh
U can use the following piece in the weblogic-ejb-jar.xml
<weblogic-enterprise-bean>
<ejb-name>UserManager</ejb-name>
<local-jndi-name>UserManager</local-jndi-name>
</weblogic-enterprise-bean>
and do the lookup in the servlet like this:
public synchronized static UserManagerLocalHome getUserManager()
{
UserManagerLocalHome home;
try
{
// Find the User Manager home object through JNDI.
Context ctx = (Context) new InitialContext();
home = (UserManagerLocalHome) ctx.lookup("UserManager");
homes.put("UserManager", home);
}
catch (Exception e)
{
System.out.println("Problem creating local home object for UserManager.");
}
return home;
}
u need not use any url like "java:comp/env/ejb/test1" as u r executing the servlet in the same environment as the ejbs
Hope this helps,
Seshu