users@glassfish.java.net

Re: Correct packaging for EJBs in WAR or EAR.

From: Roger Kitain <roger.kitain_at_oracle.com>
Date: Thu, 22 Apr 2010 14:10:46 -0400

glassfish_at_javadesktop.org wrote:

>Ryan,
>
>Maybe this will help. I don't have a standalone war, but an ear, and I figured out how to have the jar that contains the entities and the jar that contains the persistence.xml at the same level. Since I actually have multiple ejb jars with entities, this makes it so all I have to do is note that in persistence.xml. I think it's relevant to your situation and i think these are the important bits:
>
>layout:
>
>app.ear
>-- core.jar
>-- web.war
>-- persistence.jar (contains only persistence.xml)
>
>
>persistence.xml has:
><jar-file>core.jar</jar-file>
>
>
>pom.xml for web.war has stuff to generate classpath in manifest.mf and keep duplicate jars out, which may or may not matter to you:
>[code]
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <archive>
> <addMavenDescriptor>false</addMavenDescriptor>
> </archive>
> <outputFileNameMapping>@{artifactId}@.@{extension}@</outputFileNameMapping>
> <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
> <archive>
> <manifest>
> <addClasspath>true</addClasspath>
> <classpathPrefix>lib/</classpathPrefix>
> </manifest>
> </archive>
> <webresource>
> <excludes>**/persistence.xml</excludes>
> </webresource>
> </configuration>
> </plugin>
>[/code]
>
>
>pom.xml for app.ear has:
>[code]
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-ear-plugin</artifactId>
> <version>2.3.2</version>
> <configuration>
> <version>5</version>
> <generateApplicationXml>true</generateApplicationXml>
> <defaultLibBundleDir>lib</defaultLibBundleDir>
> <modules>
> <ejbModule>
> <groupId>com.xyz</groupId>
> <artifactId>core</artifactId>
> <bundleFileName>core.jar</bundleFileName>
> </ejbModule>
> <webModule>
> <groupId>com.xyz</groupId>
> <artifactId>web</artifactId>
> <contextRoot>/web</contextRoot>
> <bundleFileName>web.war</bundleFileName>
> </webModule>
> <jarModule>
> <groupId>com.xyz</groupId>
> <artifactId>persistence</artifactId>
> <bundleDir>/</bundleDir>
> <bundleFileName>persistence.jar</bundleFileName>
> </jarModule>
> </modules>
> </configuration>
> </plugin>
>[/code]
>
>-Jim
>[Message sent by forum member 'culli']
>
>http://forums.java.net/jive/thread.jspa?messageID=398544
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>