• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

WEB-INF/ejb-jar.xml within WAR file

 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
It just occurred to my mind if we have a web app structure like below, is that valid? I guess not, if not please explain how.



Appreciate if somebody can help me out.

 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Naren,

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
and
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
http://localhost:8080/WebLogger/WebLoggerServlet

and verify on your web-page:

ECHO: echo from the WebLoggerServlet

and on your console:

INFO: logBean



Regards,
Frits
 
Naren Chivukula
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Frits. I will try it out.

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.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It won't work if you define the same EJB in both ejb-jar.xml's because they share the same namespace. You will get a name clash (javax.naming.NameAlreadyBoundException).

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.

Regards,
Frits
 
Naren Chivukula
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very good point. Thanks Frits
 
no wonder he is so sad, he hasn't seen this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic