Hi All,
I am developing a simple application that displays some information from a stateless session bean in a JSP. The EJB is a local EJB and is packaged in a jar file. The jsp is packaged within a .war file. Both these together are packaged in a .ear file. I am running this on weblogic 7.0.
The error I get is the following. The deployment descriptors I use are also pasted below. Any help would be appreciated.
Thanks,
Prashant.
<Jan 14, 2004 11:22:42 AM CST> <Error> <HTTP> <101017> <[ServletContext(id=1257716,name=webapp.war,context-path=/admin)] Root cause of ServletException
javax.naming.NameNotFoundException: Unable to resolve 'app/webapp/webapp.war/1257716/comp/env/ConfigAPIEJB' Resolved: 'app/webapp/webapp.war/1257716/comp/env' Unresolved:'ConfigAPIEJB' ; remaining name 'ConfigAPIEJB'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:858)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:223)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:187)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:19
.
.
.
I) The .war files
1. web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Team Project - Config</display-name>
<description>Random</description>
<servlet>
<servlet-name>ConfigServlet</servlet-name>
<jsp-file>ConfigView.jsp</jsp-file>
</servlet>
<ejb-local-ref>
<ejb-ref-name>ConfigAPIEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>sample.ejb.cfg.ConfigAPIHomeLocal<local-home>
<local>sample.ejb.cfg.ConfigAPILocal<local>
</ejb-local-ref>
</web-app>
2. weblogic.xml
<weblogic-web-app>
<description> Config project text description </description>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>ConfigAPIEJB</ejb-ref-name>
<jndi-name>ConfigAPIEJB</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-web-app>
3. ConfigView.jsp (excerpt)
Context localCtx= new InitialContext();
cfgHome = (ConfigAPIHomeLocal) localCtx.lookup("java:comp/env/ConfigAPIEJB");
II) The ejb deployment descriptors (inside sample.jar)
1. ejb-jar.xml
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>ConfigAPIEJB</ejb-name>
<local-home>sample.ejb.cfg.ConfigAPIHomeLocal<
/local-home> <local>sample.ejb.cfg.ConfigAPILocal</local>
<ejb-class>sample.ejb.cfg.ConfigAPIBean</ejb-c
lass>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
2. weblogic-ejb-jar.xml
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>ConfigAPIEJB</ejb-name>
<stateless-session-descriptor>
<pool>
<max-beans-in-free-pool>1</max-beans-in-free-pool>
<initial-beans-in-free-pool>1</initial-beans-in-free-poo
l>
</pool>
</stateless-session-descriptor>
<jndi-name>ConfigAPIEJB</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
III) Application (.ear) files
1. application.xml
<application>
<display-name>Config EAR</display-name>
<description>Application to display ejb config</description>
<module>
<web>
<web-uri>webapp.war</web-uri>
<context-root>admin</context-root>
</web>
</module>
<module>
<ejb>sample.jar</ejb>
</module>
</application>
-
Accessing Local Stateless EJB directly from a JSP (6 messages)
- Posted by: Prashant Gupta
- Posted on: January 14 2004 14:51 EST
Threaded Messages (6)
- Accessing Local Stateless EJB directly from a JSP by stephen smithstone on January 14 2004 15:46 EST
- Accessing Local Stateless EJB directly from a JSP by Prashant Gupta on January 14 2004 16:36 EST
- Accessing Local Stateless EJB directly from a JSP by Alexey Titorenko on January 16 2004 03:13 EST
-
Accessing Local Stateless EJB directly from a JSP by Prashant Gupta on January 16 2004 03:04 EST
-
Accessing Local Stateless EJB directly from a JSP by Alexey Titorenko on January 19 2004 02:26 EST
- Accessing Local Stateless EJB directly from a JSP by Prashant Gupta on January 20 2004 12:42 EST
-
Accessing Local Stateless EJB directly from a JSP by Alexey Titorenko on January 19 2004 02:26 EST
-
Accessing Local Stateless EJB directly from a JSP by Prashant Gupta on January 16 2004 03:04 EST
-
Accessing Local Stateless EJB directly from a JSP[ Go to top ]
- Posted by: stephen smithstone
- Posted on: January 14 2004 15:46 EST
- in response to Prashant Gupta
have you tried java:comp/env/ejb/<EJBNAME> ? -
Accessing Local Stateless EJB directly from a JSP[ Go to top ]
- Posted by: Prashant Gupta
- Posted on: January 14 2004 16:36 EST
- in response to stephen smithstone
Hello Stephen,
Yes, I have tried to change the lookup in the jsp to "java:comp/env/ejb/ConfigAPIEJB".
What I dont undertand is whether registering the EJB with the <jndi-name> element set to "ConfigAPIEJB" (in weblogic-ejb-jar.xml) automatically sets the ENC registery name to ejb/ConfigAPIEJB or do I have to try and change the element <jndi-name> also to "ejb/ConfigAPIEJB" (in weblogic-ejb-jar.xml)?
I figured that as with the usual JNDI lookup, it would just put it into the base (=java:comp/env) + jndi-name (=ConfigAPIEJB). If this is the case, then I am kinda stuck understanding why the lookup fails.
Thanks,
Prashant. -
Accessing Local Stateless EJB directly from a JSP[ Go to top ]
- Posted by: Alexey Titorenko
- Posted on: January 16 2004 03:13 EST
- in response to stephen smithstone
Hi!
Try to add <ejb-link>sample.jar#ConfigAPIEJB</ejb-link> element right before the </ejb-local-ref> closing tag in your web.xml. -
Accessing Local Stateless EJB directly from a JSP[ Go to top ]
- Posted by: Prashant Gupta
- Posted on: January 16 2004 15:04 EST
- in response to Alexey Titorenko
Hi Alexey,
Thank you for your suggestion.
I tried adding that line and it doesnt appear to help. Is there something special that needs to be done since the .war and .jar files are packaged together in a .ear?
To get things working, I changed the local bean to a remote bean and it works just fine. I would prefer to get the local bean working though :(
Thanks again,
Prashant. -
Accessing Local Stateless EJB directly from a JSP[ Go to top ]
- Posted by: Alexey Titorenko
- Posted on: January 19 2004 02:26 EST
- in response to Prashant Gupta
Try also to replace <jndi-name>ConfigAPIEJB</jndi-name>
with <local-jndi-name>ConfigAPIEJB</local-jndi-name> in your weblogic-ejb-jar.xml -
Accessing Local Stateless EJB directly from a JSP[ Go to top ]
- Posted by: Prashant Gupta
- Posted on: January 20 2004 12:42 EST
- in response to Alexey Titorenko
Hi Alexey,
Thanks for your suggestions. I finally managed to get it working.
The solution seems to be to remove the binding of jndi for the local ejb. So I modified my weblogic.xml by removing the <reference-descriptor>. Also added the <ejb-link> element in web.xml. I removed the binding of ejb to jndi (<local-jndi-name>) from the weblogic-ejb-jar.xml too. Finally I added a "Class-Path:" entry to the sample.jar in my webapp's Manifest file and everything looks ok now.
Regards,
Prashant.