I read "Class Loading in AS7" several times and also the JEE6 spec. as I
went about configuring the poms. My goal was to produce an EAR that was
portable. Per spec. the sub deployments (e.g. modules) within the EAR are
by default isolated from each other. JBoss provides a means for modules to
not be isolated, but such a means is JBoss-specific. According to the
spec. the only way to configure access between sub deployments is an
explicit Class-Path entry in the MANIFEST.MF, and this is what I want to do.
I configured the poms such that maven-war plugin added the EJB module
Class-Path entry to the WAR's MANIFEST.MF and as a result the WAR module
had access to the EJB module. That part of the deployment works fine. The
way I did the configuration was to first add the following dependency:
<dependency>
<groupId>com.patrac</groupId>
<artifactId>Patrac-ejb</artifactId>
<type>ejb</type>
<optional>true</optional>
</dependency>
(the <optional>true</optional> flag told maven-war-plugin to add the
Class-Path entry to MANIFEST.MF but not add EJB JAR to the WAR's
WEB-INF/lib directory, and this was as it should have been). The
dependency and its flag is not all that was required. Second, the
maven-war-plugin also needed the following flag:
<manifest>
<addClasspath>true</addClasspath>
</manifest>
Now, the problem is that maven-war-plugin wants to add Class-Path entries
for all other dependencies that are <scope>required</scope>, such as
RichFaces, to MANIFEST.MF, and this is what's creating the deploy error
messages. Whereas the EJB JAR belongs in the root directory of the EAR and
requires a Class-Path entry, the RichFaces JARs belong in WEB-INF/lib and
must not have Class-Path entries. Adding RichFaces Class-Path entries
causes the deployment error messages.
To my knowledge there are only three options available for configuring
Class-Path entries for dependencies:
1. <optional>true</optional>: put the Class-Path entry in MANIFEST.MF but
do not put the JAR in WEB-INF/lib
2. <scope>provided</scope>: neither put the Class-Path entry in
MANIFEST.MF nor put the JAR in WEB-INF/lib
3. (no flag at all): both put the Class-Path entry in MANIFEST.MF and put
the JAR in WEB-INF/lib
Because RichFaces JAR lives in WEB-INF/lib options 1 & 2 aren't
appropriate. Option 3 is not appropriate because, although RichFaces JAR
must be in WEB-INF/lib there must not be a Class-Path entry for RichFaces.
Option 3 is what I'm currently using just so that I can deploy and make the
webapp run. However, JBoss displays the annoying Class-Path reference
warning messages, and rightly so. The class loader cannot find the
RichFaces JAR where the Class-Path entry says it should be, at the root of
the EAR.
I need an option 4 that does not put the Class-Path entry in MANIFEST.MF
and puts the JAR in WEB-INF/lib.
Taking a look at the "WAR Manifest Customization" page,
http://maven.apache.org/plugins/maven-war-plugin/examples/war-manifest-guide.html,
the above three options are given as examples, along with a note:
*Note:* No way is shown how to include a dependency in WEB-INF/lib but not
in the manifest classpath.
At the bottom of the page, it says the following:
Check the Guide to Working with
Manifests<http://maven.apache.org/guides/mini/guide-manifest.html>for
more examples. I need the example that is not shown. When I click
through to the guide, it says only the following:
"In order to modify the manifest of the archive produced by the packaging
plug-ins you need to create a configuration for it. The definitive guide
for this is the site for the Maven Archiver shared
component<http://maven.apache.org/shared/maven-archiver/index.html>.
This component is used by all our packaging plugins."
The link sends one right back to the "WAR Manifest Customization" page.
On Sun, Feb 12, 2012 at 10:40 PM, Stephen Coy <[email protected]> wrote:
> You may want to read <
> https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7>.
>
>
>
> On 11/02/2012, at 2:22 PM, Patrick Garner wrote:
>
> > I've used the maven-ear-plugin with the maven-war-plugin and
> > maven-ejb-plugin to successfully deploy and run an application packaged
> as
> > EAR to Jboss AS7.
> >
> > .
> > |-- META-INF
> > | |-- application.xml
> > | |-- MANIFEST.MF
> > | `-- maven
> > | `-- com.patrac
> > | `-- Patrac-ear
> > | |-- pom.properties
> > | `-- pom.xml
> > |-- Patrac-ejb-1.0-SNAPSHOT.jar
> > `-- Patrac-web-1.0-SNAPSHOT.war
> >
> > In the application source code directories, the poms are located as
> follows:
> >
> > .
> > |
> > |-- Patrac-ear
> > | `-- pom.xml
> > |-- Patrac-ejb
> > | `-- pom.xml
> > |-- Patrac-web
> > | `-- pom.xml
> > `-- pom.xml
> >
> > I can't figure out how to stop a few annoying warning messages when I
> > deploy the application:
> >
> > 12:32:03,958 WARN [org.jboss.as.server.
> > deployment] (MSC service thread 1-2) Class Path entry
> > richfaces-components-ui-4.0.0.Final.jar in
> > "/content/Patrac.ear/Patrac-web-1.0-SNAPSHOT.war" does not point to a
> > valid jar for a Class-Path reference.
> > 12:32:03,970 WARN [org.jboss.as.server.deployment] (MSC service thread
> > 1-2) Class Path entry richfaces-components-api-4.0.0.Final.jar in
> > "/content/Patrac.ear/Patrac-web-1.0-SNAPSHOT.war" does not point to a
> > valid jar for a Class-Path reference.
> > 12:32:03,984 WARN [org.jboss.as.server.deployment] (MSC service thread
> > 1-2) Class Path entry richfaces-core-api-4.0.0.Final.jar in
> > "/content/Patrac.ear/Patrac-web-1.0-SNAPSHOT.war" does not point to a
> > valid jar for a Class-Path reference.
> > 12:32:03,989 WARN [org.jboss.as.server.deployment] (MSC service thread
> > 1-2) Class Path entry richfaces-core-impl-4.0.0.Final.jar in
> > "/content/Patrac.ear/Patrac-web-1.0-SNAPSHOT.war" does not point to a
> > valid jar for a Class-Path reference.
> >
> > Patrac-web-1.0-SNAPSHOT.war!META-INF/MANIFEST.MF looks like this:
> >
> > Manifest-Version: 1.0
> > Built-By: pgarner
> > Build-Jdk: 1.7.0_02
> > Class-Path: Patrac-ejb-1.0-SNAPSHOT.jar richfaces-components-ui-4.0.0.
> > Final.jar richfaces-components-api-4.0.0.Final.jar richfaces-core-api
> > -4.0.0.Final.jar richfaces-core-impl-4.0.0.Final.jar cssparser-0.9.5.
> > jar sac-1.3.jar guava-r08.jar
> > Created-By: Apache Maven
> > Archiver-Version: Plexus Archiver
> >
> > The ejb class-path entry needs to be present for portability but the
> > richfaces, cssparser and guava class-path entries should not be in the
> > manifest. The problem is that my WAR depends on all of these JARs, but
> > some of them live in WEB-INF/lib and one lives in the root directory of
> the
> > EAR. Each dependency needs to be present in Patrac-web/pom.xml so that
> > Maven will put the JARs in the correct places, but I cannot figure out
> how
> > to instruct Maven to only include a Class-Path entry for
> > Patrac-ejb-1.0-SNAPSHOT.jar (and to leave the other JARs out of the
> > manifest).
> >
> > <!--
> > According to JEE 6 spec, the application is portable if
> > Patrac-web.war's META-INF/MANIFEST.MF contains a Class-Path entry
> > for Patrac-ejb-1.0-SNAPSHOT.jar.
> >
> > <optional>true</optional> is the flag that maven-war-plugin uses
> > to put the entry in MANIFEST.MF without copying
> > Patrac-ejb-1.0-SNAPSHOT.jar
> > into WEB-INF/lib. This is what I want.
> >
> > <scope>provided</scope> would cause maven-war-plugin to NEITHER
> > put the entry in MANIFEST.MF nor copy Patrac-ejb.jar into
> > WEB-INF/lib,
> > which would not be good.
> >
> > No tag at all would cause maven-war-plugin to BOTH put the entry in
> > MANIFEST.MF and copy Patrac-ejb.jar into WEB-INF/lib, which would
> > also not be good.
> > -->
> > <dependency>
> > <groupId>com.patrac</groupId>
> > <artifactId>Patrac-ejb</artifactId>
> > <type>ejb</type>
> > <optional>true</optional>
> > </dependency>
> >
> > <!--
> > These two dependencies are used to copy
> > the other JAR files into WEB-INF/lib and there
> > should not be any class-path entries for such
> > JARs in MANIFEST.MF, in order to avoid the
> > error messages.
> > -->
> > <dependency>
> > <groupId>org.richfaces.ui</groupId>
> > <artifactId>richfaces-components-ui</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.richfaces.core</groupId>
> > <artifactId>richfaces-core-impl</artifactId>
> > </dependency>
> >
> > I'm using the most recent maven-war-plugin version, 2.2. How do I tell
> the
> > maven-war-plugin to put the "non-ejb" JARs into WEB-INF/lib while not
> > putting class-path entries in MANIFEST.MF?
> >
> > Any advice or pointers you have are greatly appreciated.
> >
> > References:
> >
> > - [Maven War Plugin](http://maven.apache.org/plugins/maven-war-plugin/)
> > - [Maven Ear Plugin](http://maven.apache.org/plugins/maven-ear-plugin/)
> >
> > Thanks,
> > Pat
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>