Hi Riaz,
I believe we only inject EJBs into servlets if both the EJBs and the
Servlets are in the same application - i.e. your EJBs are inside your .war
file (like the ejb-examples webapp in our examples), your EJB jar is in
WEB-INF/lib (as you've discovered), or if you package your EJB jar and .war
file together in an EAR file.
If your EJBs are deployed separately to your web app, I don't think the
deployer will be able to figure out where your EJBs are to inject them into
the servlet.
I guess you might be able to add some ejb-refs to your web.xml that
reference another ejb-jar. I'm thinking along the lines of
<ejb-ref>
<ejb-ref-name>com.foo.shapes.SquareBean/orangeRemote</ejb-ref-name>
<ejb-link>colorsApp.jar#OrangeBean</ejb-link>
</ejb-ref>
from http://openejb.apache.org/3.0/ejb-refs.html
I'm only thinking out loud though - I've never tried it. Personally I'd
stick with either your current approach or building an EAR file.
Hope that's some help.
Jon
On Sun, Aug 2, 2009 at 9:13 PM, riazb <[email protected]> wrote:
>
> Well, I removed the MyEJB.jar from where it was and placed it within the
> WEB-INF/lib folder of my test web project.
> Re-configured OpenEJB via openejb.xml and removed the 'Deployments' tag.
>
> Looking at the logs, OpenEJB picks up the MyEJB.jar automatically from
> within my web project's lib folder and initializes everything.
>
> Now it works.
>
> So, is this a requirement as to where the EJB jar is located? Does it have
> to be within my web project? Or Tomcat's class path maybe?
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/Failing-to-inject-%40EJB-into-a-servlet-tp24781514p24781640.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>