java.lang.ClassNotFoundException: javax.crypto.spec.SecretKeySpec

Issue #71 resolved
unnikrishnan kv created an issue

Hello Team, Am working in AEM project. I need to add jose4j for livefyre dependencies.So i converted jose4j 4.3 to OSGI bundle and uploaded in AEM. It is working fine in compile time and run time throws exception like "Caused by: java.lang.ClassNotFoundException: javax.crypto.spec.SecretKeySpec". Could you please help to fix this.

Caused by: java.lang.NoClassDefFoundError: javax/crypto/spec/SecretKeySpec at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2228) at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1472) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1923) at java.lang.ClassLoader.loadClass(Unknown Source) at com.livefyre.utils.LivefyreUtil.serializeAndSign(LivefyreUtil.java:62) at com.livefyre.core.Collection.buildCollectionMetaToken(Collection.java:73) at com.livefyre.core.Collection.getPayload(Collection.java:161) at com.livefyre.core.Collection.invokeCollectionApi(Collection.java:153) at com.livefyre.core.Collection.createOrUpdate(Collection.java:48) at com.mm.online.cms.aem.livefyre.LivefyreComments.setProperties(LivefyreComments.java:112) at com.mm.online.cms.aem.livefyre.LivefyreComments.<init>(LivefyreComments.java:43) ... 202 more Caused by: java.lang.ClassNotFoundException: javax.crypto.spec.SecretKeySpec not found by livefyre [544] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1500) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1923) at java.lang.ClassLoader.loadClass(Unknown Source) ... 216 more

Thanks!, Unnikrishnan

Comments (4)

  1. Brian Campbell repo owner

    I don't really know, to be honest.

    I will say that pull request #5 was to "Make OSGi bundle from resulting JAR" and that's been part of the project since v0.4.4. You might want to try with a newer version than 0.4.3. I'll note that the MANIFEST.MF from 0.5.2 has "Import-Package:...", which the attached jar manifest does not. And one of the packages is 'javax.crypto.spec' which is the package of SecretKeySpec that the exception is complaining about.

    Manifest-Version: 1.0
    Export-Package: org.jose4j.base64url;uses:="org.jose4j.lang";version="
     0.5.2",org.jose4j.http;uses:="org.jose4j.lang,javax.net.ssl,org.slf4j
     ";version="0.5.2",org.jose4j.jca;version="0.5.2",org.jose4j.json;uses
     :="org.jose4j.lang";version="0.5.2",org.jose4j.jwa;uses:="org.jose4j.
     keys,org.slf4j,org.jose4j.lang,org.jose4j.jwe,org.jose4j.zip,org.jose
     4j.jws";version="0.5.2",org.jose4j.jwe;uses:="org.jose4j.lang,javax.c
     rypto,org.jose4j.jwx,javax.crypto.spec,org.jose4j.keys,org.jose4j.jca
     ,org.jose4j.jwa,org.jose4j.mac,org.jose4j.base64url,org.slf4j,org.jos
     e4j.jwk,org.jose4j.jwe.kdf,org.jose4j.zip";version="0.5.2",org.jose4j
     .jwe.kdf;uses:="org.jose4j.lang,org.slf4j,org.jose4j.base64url,org.jo
     se4j.keys,org.jose4j.mac,javax.crypto";version="0.5.2",org.jose4j.jwk
     ;uses:="org.jose4j.jwx,org.jose4j.jwe,org.jose4j.lang,org.jose4j.keys
     ,org.jose4j.http,org.slf4j,org.jose4j.json,org.jose4j.base64url,javax
     .crypto.spec,org.jose4j.jws,org.jose4j.jwa";version="0.5.2",org.jose4
     j.jws;uses:="org.jose4j.keys,org.jose4j.jca,org.jose4j.lang,org.jose4
     j.jwa,org.slf4j,org.jose4j.mac,javax.crypto,org.jose4j.jwx,org.jose4j
     .base64url";version="0.5.2",org.jose4j.jwt.consumer;uses:="org.jose4j
     .jwt,org.jose4j.jwx,org.jose4j.jwe,org.jose4j.jws,org.jose4j.jca,org.
     jose4j.lang,org.jose4j.jwa,org.jose4j.keys.resolvers";version="0.5.2"
     ,org.jose4j.jwt;uses:="org.jose4j.json,org.jose4j.lang,org.jose4j.jwt
     .consumer,org.jose4j.base64url";version="0.5.2",org.jose4j.jwx;uses:=
     "org.jose4j.lang,org.jose4j.jwk,org.jose4j.json,org.jose4j.base64url,
     org.jose4j.jwe,org.jose4j.keys,org.jose4j.jca,org.jose4j.jws,org.jose
     4j.jwa";version="0.5.2",org.jose4j.keys;uses:="javax.crypto.spec,org.
     jose4j.lang,org.jose4j.base64url";version="0.5.2",org.jose4j.keys.res
     olvers;uses:="org.jose4j.jwx,org.jose4j.jwe,org.jose4j.lang,org.jose4
     j.jwk,org.jose4j.jws,org.slf4j,org.jose4j.keys";version="0.5.2",org.j
     ose4j.lang;uses:="org.jose4j.base64url,org.jose4j.jwt";version="0.5.2
     ",org.jose4j.mac;uses:="org.jose4j.lang,javax.crypto";version="0.5.2"
     ,org.jose4j.zip;uses:="org.jose4j.lang,org.jose4j.jwa,org.jose4j.keys
     ";version="0.5.2"
    Built-By: bcampbell
    Tool: Bnd-1.43.0
    Bundle-Name: jose4j
    Created-By: Apache Maven Bundle Plugin
    Build-Jdk: 1.7.0_51
    Bundle-Version: 0.5.2
    Bnd-LastModified: 1470857619410
    Bundle-ManifestVersion: 2
    Bundle-Description: The jose.4.j library is a robust and easy to use o
     pen source implementation of JSON Web Token (JWT) and the JOSE specif
     ication suite (JWS, JWE, and JWK).     It is written in Java and reli
     es solely on the JCA APIs for cryptography.     Please see https://bi
     tbucket.org/b_c/jose4j/wiki/Home for more info, examples, etc..
    Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
    Import-Package: javax.crypto,javax.crypto.spec,javax.net.ssl,org.jose4
     j.lang,org.slf4j;version="[1.7,2)"
    Bundle-SymbolicName: org.bitbucket.b_c.jose4j
    Archiver-Version: Plexus Archiver
    
  2. Log in to comment