In testing that servlets that are loaded on startup could access EJBs
in their init method I have run across an ordering problem with the
AbstractWebContainer deploy method. Both the Jetty and Tomcat
based subclasses show the same type of problem. The Jetty stack trace
seen during the deploy of a web app with such a load on startup
servlet is show below.
The problem is that to setup the java:comp/env environment I need the
web app class loader and the deployment descriptor information, but to obtain
this requires initializing the web container. This has the side effect of loading
the servlets that have the load-on-startup element set.
To fix this issue it seems that instead of asking the web container to initialize
and then build the JNDI env based on data returned from the initialization process,
a callback interface needs to be passed to performDeploy(). The web container
would then callback into the AbstractWebContainer with the web app class loader,
web-app descriptor element and optional jboss-web descriptor element.
I can do this with Tomcat. Will this approach work for Jetty and other web
containers people are tying to integrate?
[J2EE Deployer Default] Starting module jbosstest-web.war
...
[Jetty] JSP: init
[Default] javax.naming.NameNotFoundException: env not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:473)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:481)
at org.jnp.server.NamingServer.getObject(NamingServer.java:487)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:457)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at
org.jboss.test.web.servlets.EJBOnStartupServlet.init(EJBOnStartupServlet.java:35)
at com.mortbay.Jetty.Servlet.ServletHolder.getServlet(ServletHolder.java:306)
at com.mortbay.Jetty.Servlet.ServletHolder.initialize(ServletHolder.java:194)
at com.mortbay.Jetty.Servlet.ServletHandler.start(ServletHandler.java:185)
at com.mortbay.HTTP.HandlerContext.start(HandlerContext.java:1053)
at
com.mortbay.Jetty.Servlet.WebApplicationContext.start(WebApplicationContext.java:330)
at org.jboss.jetty.Jetty.deploy(Jetty.java:219)
at org.jboss.jetty.JettyService.performDeploy(JettyService.java:321)
at org.jboss.web.AbstractWebContainer.deploy(AbstractWebContainer.java:153)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:492)
at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:218)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at org.jboss.ejb.AutoDeployer.deploy(AutoDeployer.java:379)
at org.jboss.ejb.AutoDeployer.run(AutoDeployer.java:217)
at java.lang.Thread.run(Thread.java:484)
[Jetty]
javax.servlet.ServletException: Failed to init EJBOnStartupServlet
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development