You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Benoît Thiébault <th...@artenum.com> on 2012/04/11 12:12:43 UTC
Converting XStream to OSGi
Hi everyone,
In my OSGi-based project, I need to use the XStream open source library
http://xstream.codehaus.org/
Unfortunately, there is no OSGi version of the project, so I created an
empty Maven project and added XStream as a dependency as follows
(pom.xml file is attached):
<dependencies>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
I then configured BND to embed XStream and its dependencies:
<!-- Packaging -->
<packaging>bundle</packaging>
<!-- Build -->
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>
com.thoughtworks.xstream,
com.thoughtworks.xstream.io,
com.thoughtworks.xstream.io.xml,
</Export-Package>
<Embed-Dependency>
*;groupId=com.thoughtworks.xstream;artifactId=xstream;version=1.4.2,
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
When I look in the generated Jar, I find an xstream-1.4.2.jar file as
well as the com/toughworks/xstream folder hierarchy with the class files
(which seems redundant with the xstream-1.4.2.jar file, but the class in
the latest are not the same than the ones under com/toughworks/xstream
folder).
My problem is that there is no trace anywhere of the transitive
dependencies.
When installing the bundle, I have the following error message in felix:
ERROR: Bundle xstream-osgi [5] Error starting
file:/home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar
(org.osgi.framework.BundleException: Unresolved constraint in bundle
xstream-osgi [5]: Unable to resolve 5.0: missing requirement [5.0]
osgi.wiring.package; (osgi.wiring.package=com.bea.xml.stream))
What am I doing wrong? Is there a cleaner way to convert to OSGi a
library that I do not develop?
Kind regards,
Ben
Re: Converting XStream to OSGi
Posted by Christian Schneider <ch...@die-schneider.net>.
I guess you might need another bundle.
Try mvn:org.codehaus.woodstox/woodstox-core-asl/4.1.1 it exports this
package.
Christian
Am 11.04.2012 15:37, schrieb Benoît Thiébault:
> I tried that bundle and had a unresolved constraint error on
> com.ctc.wstx.stax...
>
> But thanks for the link
>
> Le 11/04/2012 12:31, Christian Schneider a écrit :
>> Hi,
>>
>> before you go too deep with this check this bundle:
>> http://search.maven.org/#artifactdetails|org.apache.servicemix.bundles|org.apache.servicemix.bundles.xstream|1.4.2_2|bundle
>>
>>
>> Christian
>>
>> Am 11.04.2012 12:12, schrieb Benoît Thiébault:
>>> Hi everyone,
>>>
>>> In my OSGi-based project, I need to use the XStream open source
>>> library http://xstream.codehaus.org/
>>>
>>> Unfortunately, there is no OSGi version of the project, so I created
>>> an empty Maven project and added XStream as a dependency as follows
>>> (pom.xml file is attached):
>>> <dependencies>
>>> <dependency>
>>> <groupId>com.thoughtworks.xstream</groupId>
>>> <artifactId>xstream</artifactId>
>>> <version>1.4.2</version>
>>> </dependency>
>>> </dependencies>
>>>
>>> I then configured BND to embed XStream and its dependencies:
>>> <!-- Packaging -->
>>> <packaging>bundle</packaging>
>>> <!-- Build -->
>>> <build>
>>> <plugins>
>>> <plugin>
>>> <groupId>org.apache.felix</groupId>
>>> <artifactId>maven-bundle-plugin</artifactId>
>>> <version>2.3.7</version>
>>> <extensions>true</extensions>
>>> <configuration>
>>> <instructions>
>>> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
>>> <Export-Package>
>>> com.thoughtworks.xstream,
>>> com.thoughtworks.xstream.io,
>>> com.thoughtworks.xstream.io.xml,
>>> </Export-Package>
>>> <Embed-Dependency>
>>>
>>> *;groupId=com.thoughtworks.xstream;artifactId=xstream;version=1.4.2,
>>> </Embed-Dependency>
>>> <Embed-Transitive>true</Embed-Transitive>
>>> </instructions>
>>> </configuration>
>>> </plugin>
>>> </plugins>
>>> </build>
>>>
>>> When I look in the generated Jar, I find an xstream-1.4.2.jar file
>>> as well as the com/toughworks/xstream folder hierarchy with the
>>> class files (which seems redundant with the xstream-1.4.2.jar file,
>>> but the class in the latest are not the same than the ones under
>>> com/toughworks/xstream folder).
>>>
>>> My problem is that there is no trace anywhere of the transitive
>>> dependencies.
>>> When installing the bundle, I have the following error message in
>>> felix:
>>> ERROR: Bundle xstream-osgi [5] Error starting
>>> file:/home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar
>>> (org.osgi.framework.BundleException: Unresolved constraint in bundle
>>> xstream-osgi [5]: Unable to resolve 5.0: missing requirement [5.0]
>>> osgi.wiring.package; (osgi.wiring.package=com.bea.xml.stream))
>>>
>>> What am I doing wrong? Is there a cleaner way to convert to OSGi a
>>> library that I do not develop?
>>>
>>> Kind regards,
>>>
>>> Ben
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
>
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Converting XStream to OSGi
Posted by Benoît Thiébault <th...@artenum.com>.
I tried that bundle and had a unresolved constraint error on
com.ctc.wstx.stax...
But thanks for the link
Le 11/04/2012 12:31, Christian Schneider a écrit :
> Hi,
>
> before you go too deep with this check this bundle:
> http://search.maven.org/#artifactdetails|org.apache.servicemix.bundles|org.apache.servicemix.bundles.xstream|1.4.2_2|bundle
>
>
> Christian
>
> Am 11.04.2012 12:12, schrieb Benoît Thiébault:
>> Hi everyone,
>>
>> In my OSGi-based project, I need to use the XStream open source
>> library http://xstream.codehaus.org/
>>
>> Unfortunately, there is no OSGi version of the project, so I created
>> an empty Maven project and added XStream as a dependency as follows
>> (pom.xml file is attached):
>> <dependencies>
>> <dependency>
>> <groupId>com.thoughtworks.xstream</groupId>
>> <artifactId>xstream</artifactId>
>> <version>1.4.2</version>
>> </dependency>
>> </dependencies>
>>
>> I then configured BND to embed XStream and its dependencies:
>> <!-- Packaging -->
>> <packaging>bundle</packaging>
>> <!-- Build -->
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>org.apache.felix</groupId>
>> <artifactId>maven-bundle-plugin</artifactId>
>> <version>2.3.7</version>
>> <extensions>true</extensions>
>> <configuration>
>> <instructions>
>> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
>> <Export-Package>
>> com.thoughtworks.xstream,
>> com.thoughtworks.xstream.io,
>> com.thoughtworks.xstream.io.xml,
>> </Export-Package>
>> <Embed-Dependency>
>>
>> *;groupId=com.thoughtworks.xstream;artifactId=xstream;version=1.4.2,
>> </Embed-Dependency>
>> <Embed-Transitive>true</Embed-Transitive>
>> </instructions>
>> </configuration>
>> </plugin>
>> </plugins>
>> </build>
>>
>> When I look in the generated Jar, I find an xstream-1.4.2.jar file as
>> well as the com/toughworks/xstream folder hierarchy with the class
>> files (which seems redundant with the xstream-1.4.2.jar file, but the
>> class in the latest are not the same than the ones under
>> com/toughworks/xstream folder).
>>
>> My problem is that there is no trace anywhere of the transitive
>> dependencies.
>> When installing the bundle, I have the following error message in felix:
>> ERROR: Bundle xstream-osgi [5] Error starting
>> file:/home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar
>> (org.osgi.framework.BundleException: Unresolved constraint in bundle
>> xstream-osgi [5]: Unable to resolve 5.0: missing requirement [5.0]
>> osgi.wiring.package; (osgi.wiring.package=com.bea.xml.stream))
>>
>> What am I doing wrong? Is there a cleaner way to convert to OSGi a
>> library that I do not develop?
>>
>> Kind regards,
>>
>> Ben
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>
>
--
Dr Benoît Thiébault
Project Manager
Artenum Toulouse - Science& Groupware
http://www.artenum.com
Bâtiment Calfocenter
10, rue Marguerite-Long
31320 Castanet-Tolosan
France
Phone: +33 (0)5 82 95 19 00
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Converting XStream to OSGi
Posted by Christian Schneider <ch...@die-schneider.net>.
Hi,
before you go too deep with this check this bundle:
http://search.maven.org/#artifactdetails|org.apache.servicemix.bundles|org.apache.servicemix.bundles.xstream|1.4.2_2|bundle
Christian
Am 11.04.2012 12:12, schrieb Benoît Thiébault:
> Hi everyone,
>
> In my OSGi-based project, I need to use the XStream open source
> library http://xstream.codehaus.org/
>
> Unfortunately, there is no OSGi version of the project, so I created
> an empty Maven project and added XStream as a dependency as follows
> (pom.xml file is attached):
> <dependencies>
> <dependency>
> <groupId>com.thoughtworks.xstream</groupId>
> <artifactId>xstream</artifactId>
> <version>1.4.2</version>
> </dependency>
> </dependencies>
>
> I then configured BND to embed XStream and its dependencies:
> <!-- Packaging -->
> <packaging>bundle</packaging>
> <!-- Build -->
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <version>2.3.7</version>
> <extensions>true</extensions>
> <configuration>
> <instructions>
> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
> <Export-Package>
> com.thoughtworks.xstream,
> com.thoughtworks.xstream.io,
> com.thoughtworks.xstream.io.xml,
> </Export-Package>
> <Embed-Dependency>
>
> *;groupId=com.thoughtworks.xstream;artifactId=xstream;version=1.4.2,
> </Embed-Dependency>
> <Embed-Transitive>true</Embed-Transitive>
> </instructions>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> When I look in the generated Jar, I find an xstream-1.4.2.jar file as
> well as the com/toughworks/xstream folder hierarchy with the class
> files (which seems redundant with the xstream-1.4.2.jar file, but the
> class in the latest are not the same than the ones under
> com/toughworks/xstream folder).
>
> My problem is that there is no trace anywhere of the transitive
> dependencies.
> When installing the bundle, I have the following error message in felix:
> ERROR: Bundle xstream-osgi [5] Error starting
> file:/home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar
> (org.osgi.framework.BundleException: Unresolved constraint in bundle
> xstream-osgi [5]: Unable to resolve 5.0: missing requirement [5.0]
> osgi.wiring.package; (osgi.wiring.package=com.bea.xml.stream))
>
> What am I doing wrong? Is there a cleaner way to convert to OSGi a
> library that I do not develop?
>
> Kind regards,
>
> Ben
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com
Re: Converting XStream to OSGi
Posted by Benoît Thiébault <th...@artenum.com>.
Hi Felix and thanks for your answer,
I used the <_exportcontents> directive instead of the <Export-Package>
directive and did not notice any difference. Still only XStream files in
the Jar, no dependency (maybe this is normal, I only export XStream
packages, not its dependencies).
I used the inline argument and now the generated jar only contains class
files, no more embedded jar. Looks cleaner that way.
Regarding the optional import argument, I had to explicitly declare all
the imports (before, I used no <Import-Package> tag, which is the same
as <Import-Package>*</Import-Package>).
Now, I have the following:
<Import-Package>
com.bea.xml.stream;resolution:=optional,
com.ctc.wstx.stax;resolution:=optional,
javax.security.auth,
javax.swing,
javax.swing.plaf,
javax.xml.datatype,
javax.xml.namespace,
javax.xml.parsers,
javax.xml.stream,
javax.xml.transform,
javax.xml.transform.sax,
javax.xml.transform.stream,
net.sf.cglib.proxy;resolution:=optional,
nu.xom;resolution:=optional,
org.codehaus.jettison;resolution:=optional,
org.codehaus.jettison.mapped;resolution:=optional,
org.dom4j;resolution:=optional,
org.dom4j.io;resolution:=optional,
org.dom4j.tree;resolution:=optional,
org.jdom;resolution:=optional,
org.jdom.input;resolution:=optional,
org.joda.time;resolution:=optional,
org.joda.time.format;resolution:=optional,
org.kxml2.io;resolution:=optional,
org.w3c.dom,
org.xml.sax,
org.xml.sax.helpers,
org.xmlpull.mxp1;resolution:=optional,
org.xmlpull.v1;resolution:=optional,
sun.misc,
sun.reflect
</Import-Package>
For sun.misc and sun.reflect, I created two empty OSGi bundles just
exporting the packages to make them available in OSGi context.
Notice there are plenty of "resolution:=optional" arguments. I am not
very happy about those, I just added one for each unresolved constraint
error message in Felix.
It seems to work (I started the bundle and successfully used some basic
functions of XStream with another one), but I am not very confident with
the way I declared almost everything as optional...
Kind regards,
Ben
Le 11/04/2012 13:58, Felix Meschberger a écrit :
> Hi,
>
> Am 11.04.2012 um 12:12 schrieb Benoît Thiébault:
>
> Hi everyone,
>
> In my OSGi-based project, I need to use the XStream open source library http://xstream.codehaus.org/
>
> ...
> <Export-Package>
> com.thoughtworks.xstream,
> com.thoughtworks.xstream.io,
> com.thoughtworks.xstream.io.xml,
> </Export-Package>
> <Embed-Dependency>
> *;groupId=com.thoughtworks.xstream;artifactId=xstream;version=1.4.2,
> </Embed-Dependency>
> ...
> When I look in the generated Jar, I find an xstream-1.4.2.jar file as well as the com/toughworks/xstream folder hierarchy with the class files (which seems redundant with the xstream-1.4.2.jar file, but the class in the latest are not the same than the ones under com/toughworks/xstream folder).
>
> Looks like you would want to use the<_exportcontents> directive instead of the<Export-Package> directive. The former just creates the Export-Package header while the latter also copies the packages.
>
> Also you might want to inline the library using the inline:=true directive in Embed-Dependency
>
>
> My problem is that there is no trace anywhere of the transitive dependencies.
> When installing the bundle, I have the following error message in felix:
> ERROR: Bundle xstream-osgi [5] Error starting file:/home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar<file:///home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar> (org.osgi.framework.BundleException: Unresolved constraint in bundle xstream-osgi [5]: Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=com.bea.xml.stream))
>
> This probably comes from the dependency analysis of the xtsream classes which generates the Import-Package statements. Looks like com.bea.xml.stream may be consumed by xstreams if available. You might want to define these imports as optional, such as:
>
> <Import-Package>
> com.bea.*;resolution:=optional
> </Import-Package>
>
>
> Regards
> Felix
>
>
> What am I doing wrong? Is there a cleaner way to convert to OSGi a library that I do not develop?
>
> Kind regards,
>
> Ben
> <pom.xml>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org<ma...@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org<ma...@felix.apache.org>
>
>
--
Dr Benoît Thiébault
Project Manager
Artenum Toulouse - Science& Groupware
http://www.artenum.com
Bâtiment Calfocenter
10, rue Marguerite-Long
31320 Castanet-Tolosan
France
Phone: +33 (0)5 82 95 19 00
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Converting XStream to OSGi
Posted by Felix Meschberger <fm...@adobe.com>.
Hi,
Am 11.04.2012 um 12:12 schrieb Benoît Thiébault:
Hi everyone,
In my OSGi-based project, I need to use the XStream open source library http://xstream.codehaus.org/
...
<Export-Package>
com.thoughtworks.xstream,
com.thoughtworks.xstream.io,
com.thoughtworks.xstream.io.xml,
</Export-Package>
<Embed-Dependency>
*;groupId=com.thoughtworks.xstream;artifactId=xstream;version=1.4.2,
</Embed-Dependency>
...
When I look in the generated Jar, I find an xstream-1.4.2.jar file as well as the com/toughworks/xstream folder hierarchy with the class files (which seems redundant with the xstream-1.4.2.jar file, but the class in the latest are not the same than the ones under com/toughworks/xstream folder).
Looks like you would want to use the <_exportcontents> directive instead of the <Export-Package> directive. The former just creates the Export-Package header while the latter also copies the packages.
Also you might want to inline the library using the inline:=true directive in Embed-Dependency
My problem is that there is no trace anywhere of the transitive dependencies.
When installing the bundle, I have the following error message in felix:
ERROR: Bundle xstream-osgi [5] Error starting file:/home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar<file:///home/ben/Felix-4.0.2/bundle/xstream-osgi-1.4.2.jar> (org.osgi.framework.BundleException: Unresolved constraint in bundle xstream-osgi [5]: Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=com.bea.xml.stream))
This probably comes from the dependency analysis of the xtsream classes which generates the Import-Package statements. Looks like com.bea.xml.stream may be consumed by xstreams if available. You might want to define these imports as optional, such as:
<Import-Package>
com.bea.*;resolution:=optional
</Import-Package>
Regards
Felix
What am I doing wrong? Is there a cleaner way to convert to OSGi a library that I do not develop?
Kind regards,
Ben
<pom.xml>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org<ma...@felix.apache.org>
For additional commands, e-mail: users-help@felix.apache.org<ma...@felix.apache.org>