-
1. Re: javax.servlet.ServletException: Lookup of java:/comp/env
jonlee Nov 24, 2003 9:07 AM (in response to aschuettler)You need to show the portion of code and probably the deployment descriptors so people understand what you are doing. Otherwise, only people who have played with the tutorial may be able to help.
-
2. Re: javax.servlet.ServletException: Lookup of java:/comp/env
aschuettler Nov 24, 2003 9:31 AM (in response to aschuettler)Hi,
thanks for replying. Here comes the relevant code:
1. Home Interface
package tutorial.interfaces;
public interface FiboHome
extends javax.ejb.EJBHome
{
public static final String COMP_NAME="java:comp/env/ejb/Fibo";
public static final String JNDI_NAME="Fibo";
public tutorial.interfaces.Fibo create()
throws javax.ejb.CreateException,java.rmi.RemoteException;
}
2. Relevant part of the servlet:
public class ComputeServlet extends HttpServlet {
private FiboHome home;
private String value;
[.....]
public void init() throws ServletException {
try {
Context context = new InitialContext();
value = (String) context.lookup
("java:/comp/env/Title");
Object ref = context.lookup
("java:/comp/env/ejb/Fibo");
home = (FiboHome)
portableRemoteObject.narrow
(ref, FiboHome.class);
} catch (Exception e) {
throw new ServletException("Lookup of
java:/comp/env/ failed");
}
}
}
3. Form of the Client:
Limit :
4. Servlet mapping in web.xml
<servlet-name>ComputeServlet</servlet-name>
<display-name>Computation Servlet</display-name>
<![CDATA[Servlet that compute Fibonacci suite]]>
<servlet-class>tutorial.web.ComputeServlet</servlet-class>
<servlet-mapping>
<servlet-name>ComputeServlet</servlet-name>
<url-pattern>/Compute</url-pattern>
</servlet-mapping>
Thanks for your help
Andreas -
3. Re: javax.servlet.ServletException: Lookup of java:/comp/env
jonlee Nov 24, 2003 6:26 PM (in response to aschuettler)I think you have two problems. You haven't defined the local reference - java:comp/env/... is an internal reference for your web application. It doesn't link up with the global JNDI definition.
Perhaps have a look at http://www.amitysolutions.com.au/documents/JBossJNDI-technote.pdf for some basic information on how the mappings are supposed to work. So you will need the definition in web.xml and a mapping in jboss-web.xml.
Also note that you are using the remote interfaces whereas most of the technical note covers local interfaces. The final section touches on the remote interfaces. Essentially, you need ejb-ref definitions in web.xml. You'll also need to make sure that your ejb-ref.xml and jboss.xml in your EJB deployment is correct.
Try and work through the theory anyway and post if you have any questions when creating your mapping. -
4. Re: javax.servlet.ServletException: Lookup of java:/comp/env
mopromagik Dec 3, 2003 3:40 PM (in response to aschuettler)Hi, I to just finished the tutorial and got the same problem.
The problem is caused by an error in the code of the tutorial. The line:
* @jboss.ejb-ref-jndi ref-name = "ejb/Fibo"
* jndi-name = "ejb/tutorial/Fibo"
a the to of the ComputeServlet file should read:
* @jboss.ejb-ref-jndi ref-name = "ejb/Fibo"
* jndi-name = "tutorial/ejb/Fibo"
to match the jndi-name we gave to the service.
Hope that solves your problem.
Mo -
5. Re: javax.servlet.ServletException: Lookup of java:/comp/env
dadaiut Dec 4, 2003 7:10 AM (in response to aschuettler)Change to the following line in the file :
//value = (String) context.lookup"java:/comp/env/Title");
Object ref = context.lookup("/ejb/tutorial/Fibo");