What's the difference in deploying application as EAR (with 1 EJB and 1 WAR module) vs separate modules? I want to use GlassFish 3 web profile but it does not support EAR archive. Can I simply use EJB and WAR as separate modules? Any other options?
An EAR file requires a fully Java Platform, Enterprise Edition (Java EE)- or Jakarta Enterprise Edition (EE)-compliant application server, such as WebSphere or JBoss, to run. A WAR file only requires a Java EE Web Profile-compliant application server to run, and a JAR file only requires a Java installation.
An EAR archive is a JAR file that typically contains a WAR archive for the web pages, servlets, and other web-related components, one or several EJB3 JARs that provide services (e.g., data access and transaction) to the WAR components, and some other support library JARs required by the application.
No, that is not valid. An EAR file may contain other module-level archives, such as WAR, EJB JARs, RARs, or library JARs, but it may not contain other EAR files.
An enterprise archive (EAR) file is a compressed file that contains the libraries, enterprise beans, and JAR files that the application requires for deployment. You create a JAR file when you export your application modules from IBM® Integration Designer.
There seems to be some confusion between 3 variants of deployment:
In the first situation, you have logically one application, but one that is divided in two tiers. The WEB module is isolated from the EJB module in the sense that it can consume classes from EJB module, but the EJB module can not consume classes from the WEB module. Since it's a single application local access to EJB beans can be used and injection of EJB beans works as expected.
In the second situation (which you seem to be referring to in your question) there isn't a logical single application, but really two separate modules. They do run in the same JVM, but officially Java EE does not allow to use local access and remote access has to be used (although practically local access often works anyway). Also, injection of EJB beans in beans in the web module does not work directly with a simple @EJB
annotation, but instead the lookup
attribute has to be used that specifies the global JNDI name.
Finally, the third situation (which you don't seem to mention, but 'home' mentions) is a bit similar to the first one, but there are no tiers and isolation in this case. EJB beans can access all classes from the rest of the web module directly.
The web profile only supports this last deployment situation. Both EAR and standalone EJB deployments are not supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With