tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afryer <>
Subject Accessing an EJB by name from a servlet init method fails in collapsed ear if <load-on-startup> is specified for the servlet
Date Fri, 17 Jun 2011 05:11:48 GMT
I have a war file that contains 2 jar files in WEB-INF/lib, one for entity
beans and one for stateless session ejbs (ie. collapsed ear file).

I am deploying this war file to tomcat + openejb.  In one of my servlets, I
want to access one of the stateless session ejbs in the init() method of the
servlet.  So in my web.xml I have the following declaration where the
stateless session EJB ( is
contained in one of the jar files in WEB-INF/lib...

< !-- fragment of web.xml -->


Now if I don't specify the <load-on-startup> value on my servlet, everything
works fine.  It CAN access the ejb by doing a name lookup on
"java:comp/env/PaymentSettingLocal" because the servlet is only initialized
when the first request for it happens, which is after all the ejbs have been
initialized and named in the jndi tree.

The problem occurs when I want to specify
<load-on-startup>1</load-on-startup> for the servlet.  In that case, there
is nothing in the jndi tree at that point.  It looks like the jndi is only
populated AFTER the container creates servlets.

I have verified this by creating a servlet that prints out the jndi tree in
its init() method and also in the doGet() method.  If i configure this
servlet to load-on-startup, the init() method prints out nothing, but when I
subsequently call the doGet method, the jndi tree IS populated with the
names I have configured using <ejb-local-ref> in the web.xml.

Therefore my question is, should it be possible to access an EJB from the
init() method of a servlet when the servlet is configured to

View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message