That structure is perfectly fine. Just try the following example:
Create a EJB project in Eclipse (or another IDE) and call in LoggerEJB and create the following EJB
the ejb-jar.xml (in META-INF) will be empty like this:
Export this project (right-click on the project) to an EJB JAR file and call it LoggerEJB.jar (just put it in a temp directory or on your desktop for the mean time)
Create a Dynamic Web Project in Eclipse and call it WebLogger, and add the following files:
and a ejb-jar.xml in the WEB-INF directory like this:
Move your exported EJB JAR file (LoggerEJB.jar) into WEB-INF/lib.
Create a Servlet called WebLoggerServlet into the nl.log.servlet package
and a web.xml like this:
Start your server and verify the JNDI names:
INFO: EJB5181:Portable JNDI names for EJB EchoBean: [java:global/WebLogger/EchoBean, java:global/WebLogger/EchoBean!nl.log.ejb.EchoBean]
INFO: EJB5181:Portable JNDI names for EJB LogBean: [java:global/WebLogger/LogBean, java:global/WebLogger/LogBean!nl.notes.ejb.Log]
Hit the following URL
and verify on your web-page:
and on your console:
ECHO: echo from the WebLoggerServlet
The reason I was thinking the other way was if I override or define EJB in both the ejb-jar.xmls (assume no annotations used), would it still work? Are rules similar to annotations with ejb-jar.xml within a <ejb jar>.jar(in this case may be WEB-INF/ejb-jar.xml overrides the internal ejb-jar.xml)? I'll try this out.
Important to remember is that an EJB in WEB-INF/classes is logically the same as an EJB (in a jar-file) in WEB-INF/lib.