title: ClassCastException when using javax.crypto
body: <p>I am implementing an OSGI bundle (using <a href="http://www.eclipse.org/kura/" rel="nofollow noreferrer">kura</a>) to do some AES encryption.
  I added the third library javax.crypto directly in my bundle, here is the manifest:</p>
  
  <pre><code>Manifest-Version: 1.0
  Bundle-ManifestVersion: 2
  Bundle-Name: AES
  Bundle-SymbolicName: org.eclipse.kura.AES
  Bundle-Version: 1.0.0.qualifier
  Bundle-RequiredExecutionEnvironment: JavaSE-1.7
  Import-Package: org.osgi.service.component;version="1.2.0",
   org.slf4j;version="1.7.21"
  Service-Component: component.xml
  Export-Package: org.eclipse.kura.AES.services
  Bundle-ClassPath: .,
   lib/javax-crypto.jar
  </code></pre>
  
  <p>I am getting this error when I try the decryption:</p>
  
  <pre><code>java.lang.ClassCastException: com.sun.crypto.provider.AESCipher$General cannot be cast to javax.crypto.CipherSpi
          at javax.crypto.Cipher.getInstance(Cipher.java:166)
          at org.eclipse.kura.AES.services.AesServices.decrypt(AesServices.java:33)
          at org.eclipse.kura.AES.AES_Activator.activate(AES_Activator.java:19)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
          at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
          at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
          at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
          at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
          at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
          at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
          at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
          at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
          at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
          at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
  </code></pre>
  
  <p>I am using openjdk on my raspberry pi. I tried with oracle java but still got the same issue. Either I did not completly remove the openjdk or there is another cause that I am not able to identify.
  Any ideas?</p>