tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afryer <apfr...@hotmail.com>
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 (com.pokersquid.poker.ejbs.PaymentSettingLocal) is
contained in one of the jar files in WEB-INF/lib...

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

<ejb-local-ref>
  <ejb-ref-name>PaymentSettingLocal</ejb-ref-name>
  <ejb-ref-type>Session</ejb-ref-type>
  <local>com.pokersquid.poker.ejbs.PaymentSettingLocal</local>
</ejb-local-ref>

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
load-on-startup?  



--
View this message in context: http://openejb.979440.n4.nabble.com/Accessing-an-EJB-by-name-from-a-servlet-init-method-fails-in-collapsed-ear-if-load-on-startup-is-spet-tp3604528p3604528.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message