dev@glassfish.java.net

Re: Question on EAR packaging and deployment in V3

From: Hong Zhang <hong.hz.zhang_at_oracle.com>
Date: Thu, 23 Dec 2010 09:56:30 -0500

Hi, Rama
> I have a question in regards to packaging the EAR and deployment in V3
> for fixing a Web Services issue,
> http://java.net/jira/browse/GLASSFISH-13548.
>
> The test case (available in the above issue) has the following
> structure.
> SampleService.ear
> META-INF/
> META-INF/MANIFEST.MF
> lib/
> META-INF/application.xml
> META-INF/sun-application.xml
> lib/SampleService-ejb.jar
> SampleService-ejb.jar
> SampleService-war.war
> META-INF/
> META-INF/MANIFEST.MF
> Class-Path: SampleService-ejb.jar
> WEB-INF/classes/...
> WEB-INF/web.xml
>
> Problem: Web services in SampleService-ejb.jar are processed twice via
> the ejb module and web module, and deployment fails due to this
> duplication of web services stored in different bundle descriptors.
Yes, the Java EE spec warns against packaging jar with component
annotations as an ear library jar, as that will make all the modules in
this ear that type of the component jar.
> The same EAR seemed to deploy fine on V2.
Yes, there used to be a bug that we don't process annotations in the ear
library jar in v2. And that bug got fix in v3.
> I ran into this user's blog about problems in EAR deployment while
> migrating from V2 to V3,
> http://www.shareyourwork.org/roller/ralphsjavablog/entry/jee6_and_packaging_an_ear,
> and am interested to know if the suggested methods in the blog are
> just workaround for bugs in V3 or a prescribed way to deploy in EE 6?
>
> Few questions around this issue and the blog
> (1) The above blog mentions the jars under lib are by default shared
> by all modules, Is this standard behavior even if not specified in
> application.xml?
This is defined in the JavaEE spec. The application.xml could define a
library jar directory, but if none defined, the "lib" is the default ear
library directory.
> (2) I am also running in to resource injection problems as the blog
> mentioned, Can ejbs be packaged and shared like this as in
> SampleService.ear?
In the most common case, we should only share the EJB interfaces and not
the actual EJB bean (but I suppose there could be use cases where user
actually wants to share the EJBs in all modules of ear also, making all
the modules EJB jars).
> (3) Is there a way to detect this during deployment and avoid
> duplicate web services?
I think this will be tricky to implement, but we should try to provide a
meaningful error message when this happens.

Thanks,

- Hong