Organizational Research By

Surprising Reserch Topic

Question:Deploying multiple “Web Fragment” projects within an EAR without a WAR


I have a handful or EJB jar modules which also include their web resources as described in in this question.

I would now like to deploy this as part of an EAR.

Now, I could do this as a war without any issues and that is my backup plan. However, I would like to understand if it is possible to deploy multiple "web fragment" jars into an ear to form a complete web application without having a war file in there to combine it all together.

Additionally, If I have multiple war files that depend on one or more of these jars, will I have to build them such that these jars are duplicated within the WEB-INF/lib of the war files even if the war files then end up within the same ear?

In this case, if the jar files include entities, would they also be needed in the root of the ear so that a global persistence unit can be defined?

I am on JBoss 7 though I would prefer a standard container independent solution if possible.

 


asked Sep 13, 2013 in Java Interview Questions by anonymous
edited Sep 12, 2013
0 votes
90 views



Related Hot Questions

2 Answers

0 votes

This will work on any JEE5 compliant server.

Let's assume you have

  • 2 EJB called myejb1.jar and myejb2.jar
  • 2 WAR webapps called mywebapp1.war and mywebapp2.war
  • 2 common JARs called log4j.jar and mycommon.jar

You want to package it all into an EAR file called myapp.ear.

The myapp.ear directory structure will look like this:

myapp.ear:
META-INF/application.xml
myejb1.jar
myejb2.jar
mywebapp1.war
mywebapp2.war
lib/log4j.jar
lib/mycommon.jar

The contents of your META-INF/application.xml will contain

xml version="1.0" encoding="UTF-8"?>
 xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/application_5.xsd">

    
        myejb1.jar
    
    
        myejb2.jar
    

    
        
            mywebapp1.war
            webapp1
        
    
    
        
            mywebapp2.war
            webapp2
        
    

    lib

You will be able to access your web apps via the URL

answered Sep 13, 2013 by anonymous
edited Sep 12, 2013
0 votes

This will work on any JEE5 compliant server.

Let's assume you have

  • 2 EJB called myejb1.jar and myejb2.jar
  • 2 WAR webapps called mywebapp1.war and mywebapp2.war
  • 2 common JARs called log4j.jar and mycommon.jar

You want to package it all into an EAR file called myapp.ear.

The myapp.ear directory structure will look like this:

myapp.ear:
META-INF/application.xml
myejb1.jar
myejb2.jar
mywebapp1.war
mywebapp2.war
lib/log4j.jar
lib/mycommon.jar

The contents of your META-INF/application.xml will contain

xml version="1.0" encoding="UTF-8"?>
 xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/application_5.xsd">

    
        myejb1.jar
    
    
        myejb2.jar
    

    
        
            mywebapp1.war
            webapp1
        
    
    
        
            mywebapp2.war
            webapp2
        
    

    lib

You will be able to access your web apps via the URL

answered Sep 13, 2013 by anonymous
edited Sep 12, 2013

...