ClassCastException with OSGI bundle -
i working on osgi bundle, uses javax.ws.rs-api (2.0.1). karaf having jsr311-api (1.1.1) loaded bundle. when try load osgi bundle, see following exception. there way can ignore loaded bundle?
the activate method has thrown exception java.lang.linkageerror: classcastexception: attempting castbundle://137.0:1/javax/ws/rs/ext/runtimedelegate.class bundle://177.0:1/javax/ws/rs/ext/runtimedelegate.class @ javax.ws.rs.ext.runtimedelegate.finddelegate(runtimedelegate.java:146)[137:javax.ws.rs.jsr311-api:1.1.1] @ javax.ws.rs.ext.runtimedelegate.getinstance(runtimedelegate.java:120)[137:javax.ws.rs.jsr311-api:1.1.1] @ javax.ws.rs.core.uribuilder.newinstance(uribuilder.java:95)[137:javax.ws.rs.jsr311-api:1.1.1] @ javax.ws.rs.core.uribuilder.fromuri(uribuilder.java:119)[137:javax.ws.rs.jsr311-api:1.1.1]
your bundle must import packages need versions. have create meta-inf\manifest.mf
import-package
header, contain list of packages required versions.
import-package: javax.ws.rs.ext,version="2.0.1"
list packages cause conflict. think here are:
javax.ws.rs,version="2.0.1" javax.ws.rs.client,version="2.0.1" javax.ws.rs.container,version="2.0.1" javax.ws.rs.core,version="2.0.1" javax.ws.rs.ext,version="2.0.1"
you can specify range of versions : [2.0.1, 3) , on.
real example:
import-package: org.osgi.service.blueprint; version="[1.0.0, 2.0.0)"
you can use maven-bundle-plugin
create requered manifest.mf:
<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> <bundle-description>${project.description}</bundle-description> <import-package> javax.ws.rs;version=2.0.1, javax.ws.rs.client;version=2.0.1, javax.ws.rs.container;version=2.0.1, javax.ws.rs.core;version=2.0.1, javax.ws.rs.ext;version=2.0.1, *, org.apache.camel.osgi </import-package> <export-package> your.package </export-package> </instructions> </configuration> </plugin>
don't forget install bundle version 2.0.1
Comments
Post a Comment