Has anyone managed to embed Hibernate within their bundle using Maven
and maven-bundle-plugin? I'm getting errors that seem to be the result
of bad manifest "Import-Package" sections:
----
ERROR: Error starting file:/C:/dev/felix/bundle/kurt-handler-a-1.0.0.jar
(org.osgi.framework.BundleException: Unresolved
constraint in bundle de.huss.kurt-handler-a [2]: package;
(package=com.sun.jdmk.comm))
org.osgi.framework.BundleException: Unresolved constraint in bundle
de.huss.kurt-handler-a [2]: package; (package=com.su
n.jdmk.comm)
at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3295)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1653)
at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1124)
at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:619)
----
There is a lot of guesswork involved, but I think that the bundle plugin
does not handle the <exclusions> node of a dependency and adds a package
import to the manifest anyway. It also seems possible to me that the
bundle plugin is adding imports for dependencies that are flagged as
optional. I've attached the pom.xml and the generated manifest for those
who care.
Another thought: maybe I'm missing some magic Maven artifact that I
could import to get a working Hibernate library for OSGi environments?
Thank you very much in advance!
-Dan
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.huss</groupId>
<artifactId>kurt-handler-a</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<name>Kurt Handler A</name>
<repositories>
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.huss</groupId>
<artifactId>kurt</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- Hibernate requires slf4j -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!--
Important addition because "optional" dependencies seem to confuse
the bundle plugin. Also this isn't really an optional dependency as
Hibernate REQUIRES either cglib or javassist to do its thing.
-->
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!--
The dependencies should be managed by the bundle plugin, but I
wanted a "second opinion"
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>de.huss.kurt.handler.a.api</Export-Package>
<Private-Package>de.huss.kurt.handler.a.*</Private-Package>
<Bundle-Activator>de.huss.kurt.handler.a.Activator</Bundle-Activator>
<Include-Resource>src/main/resources/</Include-Resource>
<!-- Embed all compile and runtime scope dependencies -->
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<!--
See
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
for more configuration options!
-->
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>Manifest-Version: 1.0
Bundle-ClassPath: .,hibernate-c3p0-3.3.2.GA.jar,log4j-1.2.15.jar,xml-a
pis-1.0.b2.jar,slf4j-api-1.5.8.jar,activation-1.1.jar,antlr-2.7.6.jar
,dom4j-1.6.1.jar,slf4j-log4j12-1.5.8.jar,commons-collections-3.1.jar,
hibernate-core-3.3.2.GA.jar,mail-1.4.jar,c3p0-0.9.1.jar,mysql-connect
or-java-5.1.12.jar,jta-1.1.jar,cglib-2.1.3.jar
Built-By: random
Tool: Bnd-0.0.357
Bundle-Name: Kurt Handler A
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.6.0_16
Bundle-Version: 1.0.0
Bnd-LastModified: 1270424193319
Embed-Transitive: true
Bundle-ManifestVersion: 2
Bundle-Activator: de.huss.kurt.handler.a.Activator
Embed-Dependency: *;scope=compile|runtime
Import-Package: com.ibm.ejs.jts.jta,com.ibm.ws.Transaction,com.sun.jdm
k.comm,com.sun.msv.datatype,com.sun.msv.datatype.xsd,de.huss.kurt.api
,javassist,javassist.bytecode,javassist.util.proxy,javax.jms,javax.ma
nagement,javax.naming,javax.naming.event,javax.naming.spi,javax.net,j
avax.net.ssl,javax.security.auth,javax.security.auth.callback,javax.s
ecurity.jacc,javax.security.sasl,javax.sql,javax.swing,javax.swing.bo
rder,javax.swing.event,javax.swing.table,javax.swing.text,javax.swing
.tree,javax.xml.bind,javax.xml.namespace,javax.xml.stream,javax.xml.s
tream.events,javax.xml.stream.util,javax.xml.transform.stax,org.apach
e.commons.logging,org.apache.tools.ant,org.apache.tools.ant.taskdefs,
org.apache.tools.ant.types,org.codehaus.aspectwerkz.hook,org.gjt.xpp,
org.jaxen,org.jaxen.dom4j,org.jaxen.pattern,org.jaxen.saxpath,org.jbo
ss.resource.adapter.jdbc,org.jboss.resource.adapter.jdbc.vendor,org.o
bjectweb.asm,org.objectweb.asm.attrs,org.objectweb.asm.util,org.osgi.
framework;version="1.5",org.relaxng.datatype,org.xmlpull.v1
Bundle-SymbolicName: de.huss.kurt-handler-a
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]