You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by sim085 <si...@hotmail.com> on 2010/12/15 20:06:34 UTC

How to package a JAR file in an EAR file so that this can be accessed by all other modules (ex: EJB, WAR, etc)

Hello, I have a problem when trying to package a JAR file in an EAR file. In
short my EAR file has three modules; and EJB module, a JAR module and a WAR
module. The EJB module makes use of the JAR module. My POM is as follows;

...
<modules>
   <jarModule>
      <groupId>com.test.persistence</groupId>
      <artifactId>persistence</artifactId>
      <!-- <includeInApplicationXml>true</includeInApplicationXml> -->
   </jarModule>
   <ejbModule>
      <groupId>com.test.ejb</groupId>
      <artifactId>ejb</artifactId>
   </ejbModule>
   <webModule>
      <groupId>com.test.web</groupId>
      <artifactId>web</artifactId>
   </webModule>
</modules>
...

However when I deploy the application on Geronimo I get an error telling me
that an EJB cannot be deployed because of a class in the persistence jar
file (which is used from the EJB). The exact error is as follows;

-----
The application was not deployed.

The application was not deployed.
Could not fully load class: com.test.ejb.MyEjbBean
 due to:com/test/persistence/User
 in classLoader: 
org.apache.geronimo.kernel.classloader.TemporaryClassLoader@cf0aa9b
java.lang.NoClassDefFoundError: Could not fully load class:
com.test.ejb.MyEjbBean
 due to:com/test/persistence/User
 in classLoader: 
org.apache.geronimo.kernel.classloader.TemporaryClassLoader@cf0aa9b
-----

I checked the documentation and the only thing i could see realted is the
option includeInApplicationXml. However if I set this to true then I get the
following error;

-----
Module was not an application client: persistence-1.0-SNAPSHOT.jar
-----

Does anyone know how thtough maven I can package a JAR in an EAR file so
that this can be used by any other module within that EAR file?



-- 
View this message in context: http://maven.40175.n5.nabble.com/How-to-package-a-JAR-file-in-an-EAR-file-so-that-this-can-be-accessed-by-all-other-modules-ex-EJB-WA-tp3306790p3306790.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to package a JAR file in an EAR file so that this can be accessed by all other modules (ex: EJB, WAR, etc)

Posted by Wayne Fay <wa...@gmail.com>.
> Does anyone know how thtough maven I can package a JAR in an EAR file so
> that this can be used by any other module within that EAR file?

This is a pretty straight-forward thing, usually. I know that we are
doing it for numerous projects and there are countless others using
Maven for this purpose around the world.

Are you sure you haven't run into a bug in Geronimo? Can you try
deploying your EAR file into JBoss or Weblogic or Glassfish and make
sure that is correctly assembled etc before assuming this is a Maven
problem? Or even just use the Glassfish j2ee verifier tool against the
EAR?

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to package a JAR file in an EAR file so that this can be accessed by all other modules (ex: EJB, WAR, etc)

Posted by Wayne Fay <wa...@gmail.com>.
> I do not know if the error is because I lack some configuration setting or
> else because Geronimo does not realise that the ehb module needs the
> persistence module and therefore one should be deplpoyed before the other.

The manual way to fix this: unpack the EAR that Maven produced, and
unpack the WAR and JAR inside. Tweak the files and repack until you
get something Geronimo will consume. Then go back and figure out what
configuration you might need to change inside your Maven poms to make
it work.

Or, the simpler process is to just run the j2ee verifier tool from
Glassfish against your EAR file and see what it complains about. If
you construct a proper/valid EAR file as far as the verifier is
concerned, then Geronimo should deploy it -- if it doesn't, then you
can complain to the Geronimo folks.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How to package a JAR file in an EAR file so that this can be accessed by all other modules (ex: EJB, WAR, etc)

Posted by Diego Lin <di...@synnex.com>.
 
Hi sim085,

I know the EAR you made can be deployed on JBoss successfully. Maybe,
you could try to add the Class-Path key in MANIFEST.MF of EJB JAR. If it
doesn't work yet, please refer mechanism of class loaders of Geronimo.

Hope it is helpful to you.

 
Thanks,
 
Diego

-----Original Message-----
From: sim085 [mailto:sim085@hotmail.com] 
Sent: Thursday, 16 December 2010 06:35
To: users@maven.apache.org
Subject: Re: How to package a JAR file in an EAR file so that this can
be accessed by all other modules (ex: EJB, WAR, etc)


I do have com.test.persistence project listed under the dependencies and
in fact this is added to the ear file just like the other projects (ejb
and war). However when I try to deploy the ear file I get the error from
geronimo. 

I do not know if the error is because I lack some configuration setting
or else because Geronimo does not realise that the ehb module needs the
persistence module and therefore one should be deplpoyed before the
other.
--
View this message in context:
http://maven.40175.n5.nabble.com/How-to-package-a-JAR-file-in-an-EAR-fil
e-so-that-this-can-be-accessed-by-all-other-modules-ex-EJB-WA-tp3306790p
3307114.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to package a JAR file in an EAR file so that this can be accessed by all other modules (ex: EJB, WAR, etc)

Posted by sim085 <si...@hotmail.com>.
I do have com.test.persistence project listed under the dependencies and in
fact this is added to the ear file just like the other projects (ejb and
war). However when I try to deploy the ear file I get the error from
geronimo. 

I do not know if the error is because I lack some configuration setting or
else because Geronimo does not realise that the ehb module needs the
persistence module and therefore one should be deplpoyed before the other.
-- 
View this message in context: http://maven.40175.n5.nabble.com/How-to-package-a-JAR-file-in-an-EAR-file-so-that-this-can-be-accessed-by-all-other-modules-ex-EJB-WA-tp3306790p3307114.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to package a JAR file in an EAR file so that this can be accessed by all other modules (ex: EJB, WAR, etc)

Posted by Maxime Gréau <gr...@gmail.com>.
Hi

If your request is only to include a JAR file in a EAR, don't use the module
configuration for this. You can declare the JAR lib as a dependency in your
pom like this :

<dependencies>
      <dependency>
<groupId>com.test.persistence</groupId>
 <artifactId>persistence</artifactId>
<version>1.0-SNAPSHOT</version>
 </dependency>
...
</dependencies>
<build>
 <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-ear-plugin</artifactId>
<configuration>
 <defaultLibBundleDir>/lib</defaultLibBundleDir>
<modules>
                                                  <ejbModule>

 <groupId>com.test.ejb</groupId>

 <artifactId>ejb</artifactId>
                                                 </ejbModule>
 <webModule>

 <groupId>com.test.web</groupId>

<artifactId>web</artifactId>
                                                </webModule>
</modules>
                     </plugin>
           </plugins>
</build>

Maxime Gréau.
http://mgreau.com



2010/12/15 sim085 <si...@hotmail.com>

>
> Hello, I have a problem when trying to package a JAR file in an EAR file.
> In
> short my EAR file has three modules; and EJB module, a JAR module and a WAR
> module. The EJB module makes use of the JAR module. My POM is as follows;
>
> ...
> <modules>
>   <jarModule>
>      <groupId>com.test.persistence</groupId>
>      <artifactId>persistence</artifactId>
>      <!-- <includeInApplicationXml>true</includeInApplicationXml> -->
>   </jarModule>
>   <ejbModule>
>      <groupId>com.test.ejb</groupId>
>      <artifactId>ejb</artifactId>
>   </ejbModule>
>   <webModule>
>      <groupId>com.test.web</groupId>
>      <artifactId>web</artifactId>
>   </webModule>
> </modules>
> ...
>
> However when I deploy the application on Geronimo I get an error telling me
> that an EJB cannot be deployed because of a class in the persistence jar
> file (which is used from the EJB). The exact error is as follows;
>
> -----
> The application was not deployed.
>
> The application was not deployed.
> Could not fully load class: com.test.ejb.MyEjbBean
>  due to:com/test/persistence/User
>  in classLoader:
> org.apache.geronimo.kernel.classloader.TemporaryClassLoader@cf0aa9b
> java.lang.NoClassDefFoundError: Could not fully load class:
> com.test.ejb.MyEjbBean
>  due to:com/test/persistence/User
>  in classLoader:
> org.apache.geronimo.kernel.classloader.TemporaryClassLoader@cf0aa9b
> -----
>
> I checked the documentation and the only thing i could see realted is the
> option includeInApplicationXml. However if I set this to true then I get
> the
> following error;
>
> -----
> Module was not an application client: persistence-1.0-SNAPSHOT.jar
> -----
>
> Does anyone know how thtough maven I can package a JAR in an EAR file so
> that this can be used by any other module within that EAR file?
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/How-to-package-a-JAR-file-in-an-EAR-file-so-that-this-can-be-accessed-by-all-other-modules-ex-EJB-WA-tp3306790p3306790.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>