users@glassfish.java.net

RE: using JPA from OSGI WAB in glassfish 3.1

From: Lena Svetlov <svetloe_at_hotmail.com>
Date: Thu, 3 Feb 2011 10:02:18 +0000

Hi Sahoo,

Thanks for your answer.

1. "Embed-Dependency" tag in maven-bundle plugin fills in my Bundle-ClassPath. As a result, MANIFEST.MF contains Bundle-ClassPath with a long list of jars from WEB-INF/lib. I re-checked that it also contains the JPA jar.
2. The "." in Bundle-ClassPath is a must, if I remove it the WAB doesn't find the jars needed for Import-Package dependency. I found a bug that describes the issue: https://issues.apache.org/jira/browse/FELIX-1571
(Seems like you opened it? :) )

Any advice is appreciated.

thanks,
Lena

On Wed, Feb 2, 2011 at 8:26 PM, Sahoo <sanjeeb.sahoo_at_oracle.com> wrote:



  


Hi,



1. You said you have a JPA jar. Where is it packaged in the WAB? If it
is in WEB-INF/lib, then I don't see the corresponding entry in
Bundle-ClassPath.

2. Why do you have "." in Bundle-ClassPath. The top level entries in a
WAB do not have to take part in classloading, so you don't need that.



I think what you have is because of the way you have configured
maven-bundle-plugin. It is known fact that maven-bundle-plugin does not
go very well when one has to embed jars in a "war" type artifact.
Please see [1] and change your pom.xml accordingly. Before even you try
to change your pom.xml, I suggest you simply edit the MANIFEST.MF to
take care of #1 & #2 and see if it fixes your issue or not. If it
does, then change the pom.xml as suggested.



Thanks,

Sahoo



[1] http://www.mail-archive.com/users@felix.apache.org/msg04728.html



On Wednesday 02 February 2011 10:09 PM, Lena Svetlov wrote:

  
  
   (I am new in OSGI)

  

  

I am trying to access a JPA JAR from OSGI WAB in glassfish 3.1.

  

When I deploy the OSGI WAB with JPA jar, I get the exception:

[#|2011-02-01T18:29:10.035+0200|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-1;|java.lang.RuntimeException:

java.util.zip.ZipException: duplicate entry:
META-INF/maven/com.test/test-web/pom.properties at
org.glassfish.osgijavaeebase.OSGiBundleArchive$1.run(OSGiBundleArchive.java:366)
Caused

by: java.util.zip.ZipException: duplicate entry:
META-INF/maven/com.test/test-web/pom.properties at
java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:175) at
java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:92) at
org.glassfish.osgijavaeebase.OSGiBundleArchive$1.run(OSGiBundleArchive.java:348)
|#]

  

  

More details about my JAR and WAB:

  

1) When the JPA JAR is included in non-OSGI WAR, it works correctly.
However OSGI WAB with this JPA JAR fails in deployment.

  

2) Below is a part from pom.xml that constructs a WAB:

  

                   
<artifactId>maven-bundle-plugin</artifactId>

                    <version>2.2.0</version>

                    <extensions>true</extensions>

                    <configuration>

                        <instructions>

                           
<Web-ContextPath>/testWab</Web-ContextPath>

                           
<Webapp-Context>/testWab</Webapp-Context>

                            <Export-Package/>

                            <Export-EJB>all</Export-EJB>

                            <DynamicImport-Package>javax.*,
org.xml.sax, org.xml.sax.*, org.w3c.*</DynamicImport-Package>

                           
<Bundle-ClassPath>.,WEB-INF/classes/</Bundle-ClassPath>

                           
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>

                           
<Embed-Directory>WEB-INF/lib</Embed-Directory>

                           
<Embed-Transitive>true</Embed-Transitive>

                           
<Import-Package>com.test.integration.service.*;version="1.0.0",
com.test.adapter.*;version="1.0.0",org.osgi.framework,
org.osgi.util.tracker</Import-Package>

                        </instructions>

                    </configuration>

  

Please consult