Hi,

why you don't just put this as private package. You will avoid class
loading issue this way.

In OSGi, not all is necessary an import. It could be a private package
and/or embed dependency. It means the packages are embedded in the
bundle. The bundle is "fat" but you avoid classloading issue this way,
especially when the dependency is not designed for OSGi.

Unfortunately, I wanted to create neo4j bundle at ServiceMix, but it's
not possible due to neo4j license.

Regards
JB

On 09/09/2018 20:16, Steinar Bang wrote:
>>>>>> Steinar Bang <[email protected]>:
> 
>> My bundle, ie. the bundle containing the failing component, contains an
>> import-package for org.neo4j.graphdb.
> 
>> But the bundle where the error occurs, ie. 
>> wrap_file__home_sb_.m2_repository_org_neo4j_neo4j-graphdb-api_3.4.7_neo4j-graphdb-api-3.4.7.jar
>> does *not* contain an import-package for org.neo4j.graphdb.
> 
>> Is there a way to force-add an import-package for a wrapped jar?
> 
> I did the following:
>  1. Exclude the offending dependency from the maven dependencies
>         <dependency>
>             <groupId>org.neo4j</groupId>
>             <artifactId>neo4j</artifactId>
>             <version>3.4.7</version>
>             <exclusions>
>                 <exclusion>
>                     <groupId>org.neo4j</groupId>
>                     <artifactId>neo4j-graphdb-api</artifactId>
>                 </exclusion>
>             </exclusions>
>         </dependency>
>         <dependency>
>             <groupId>org.neo4j</groupId>
>             <artifactId>neo4j-graphdb-api</artifactId>
>             <version>3.4.7</version>
>             <scope>provided</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.neo4j</groupId>
>             <artifactId>neo4j-resource</artifactId>
>             <version>3.4.7</version>
>         </dependency>
>   2. Explictly specify the wrap'ed bundle in the template feature.xml,
>      adding the org.neo4j.graphdb to 
>         <bundle 
> start-level="80">wrap:mvn:org.neo4j/neo4j-graphdb-api/3.4.7$Import-Package=org.neo4j.collection.primitive;resolution:=optional,org.neo4j.function;resolution:=optional,org.neo4j.helpers;resolution:=optional,org.neo4j.helpers.collection;resolution:=optional,org.neo4j.kernel.api.exceptions;resolution:=optional,org.neo4j.graphdb;resolution:=optional</bundle>
> 
> bundle:headers reported the wrapped mvn:org.neo4j/neo4j-graphdb-api to
> be importing org.neo4j.graphdb but I still got the exception when
> running the activator:
> ...
> Caused by: java.lang.ClassNotFoundException: 
> org.neo4j.graphdb.ResourceIterable not found by 
> wrap_file__home_sb_.m2_repository_org_neo4j_neo4j-graphdb-api_3.4.7_neo4j-graphdb-api-3.4.7.jar_Import-Package_org.neo4j.collection.primitive_resolution__optional_org.neo4j.function_resolution__optional_org.neo4j.helpers_resolution__optional_org.neo4j.helpers.collection_resolution__optional_org.neo4j.kernel.api.exceptions_resolution__optional_org.neo4j.graphdb_resolution__optional
>  [106]
> 
> Also bundle:capabilities on the wrapped mvn:org.neo4j/neo4j-resource/3.4.7
> shows the package as unused:
>  karaf@root()> bundle:capabilities 117
>  
> wrap_file__home_sb_.m2_repository_org_neo4j_neo4j-resource_3.4.7_neo4j-resource-3.4.7.jar
>  [117] provides:
>  
> ---------------------------------------------------------------------------------------------------------
>  osgi.wiring.bundle; 
> wrap_file__home_sb_.m2_repository_org_neo4j_neo4j-resource_3.4.7_neo4j-resource-3.4.7.jar
>  0.0.0 [UNUSED]
>  osgi.wiring.host; 
> wrap_file__home_sb_.m2_repository_org_neo4j_neo4j-resource_3.4.7_neo4j-resource-3.4.7.jar
>  0.0.0 [UNUSED]
>  osgi.identity; 
> wrap_file__home_sb_.m2_repository_org_neo4j_neo4j-resource_3.4.7_neo4j-resource-3.4.7.jar
>  0.0.0 [UNUSED]
>  osgi.wiring.package; org.neo4j.graphdb 0.0.0 [UNUSED]
>  karaf@root()>
> 

-- 
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to