0

I'm trying to use AWS Encryption "DirectKmsMaterialProvider" in my karaf OSGI service but it is throwing classnotfound exception:

Caused by: java.lang.ClassNotFoundException: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException not found by wrap_file__Users_rioortizr_.m2_repository_com_amazonaws_aws-dynamodb-encryption-java_1.11.0_aws-dynamodb-encryption-java-1.11.0.jar [2404] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_51] ... 45 more

I have already added my dependency in pom.xml and features.xml

in my pom...

 <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-dynamodb</artifactId>
    <version>1.11.0</version>
 </dependency>
 <dependency>
     <groupId>com.amazonaws</groupId>
     <artifactId>aws-dynamodb-encryption-java</artifactId>
     <version>1.11.0</version>
</dependency>

in features.xml...

<bundle>wrap:mvn:com.amazonaws/aws-dynamodb-encryption-java/1.11.0</bundle>
<bundle>wrap:mvn:com.amazonaws/aws-java-sdk-dynamodb/1.11.0</bundle>

Am I missing anything here?

Thanks

Regards, Rio

Rio Ortiz
  • 55
  • 4

2 Answers2

0

It seems that the aws-dynamodb-encryption-java bundle does not have the com.amazonaws.services.dynamodbv2.datamodeling package at his manifest file imports, this happens quite often with wrap.

To fix that, you can OSGi-fy the dependency just like servicemix do, doing that you can control and fix the imports-exports manually. eg: https://github.com/apache/servicemix-bundles

Cλstor
  • 445
  • 3
  • 11
0

JARs that are not OSGi bundles as dependencies of OSGI projects can be a real pain in the backside. After spending many hours trying to sort out classpath issues that arise from JARs deployed via Karaf's wrap deployer, I made it my default to embed non-OSGi dependencies into my own bundle. Check out the bundle plugin documentation about the different options. For a simple example have a look at the accepted answer of this SO thread.

While embedding dependencies solves a lot of problems, it comes with its own share of headaches. One is that you are inflating your own bundle and that you are not able to share those dependencies across multiple of your bundles. Another is that regular JARs often come with a large number of package imports that are not required at run-time or only in certain usage scenarios and are also not provided by their transitive Maven dependencies. In order to keep the size of your bundle in check you need to weed out all those dependencies and suppress the addition of those packages to your own bundle's MANIFEST. In the referenced example I can exclude 9 packages. In my "embed-heaviest" bundle this list contains about 70 packages (to embed the Titan graph library and its dependencies).

Community
  • 1
  • 1
Ralf
  • 6,735
  • 3
  • 16
  • 32