Skip to main content



      Home
Home » Eclipse Projects » Kura » ClassCastException when using third lib javax.crypto
ClassCastException when using third lib javax.crypto [message #1759810] Tue, 18 April 2017 12:08 Go to next message
Eclipse UserFriend
Hello,

I am implementing a bundle to do some AES Encryption
I added the third lib jar: javax.crypto directly in my bundle, in the manifest I have

Bundle-ClassPath: .,
 lib/javax-crypto.jar


the problem is that I am getting this exception:

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.loRaService.LoRaMessage.addReceivedInfoToLoRaMsg(LoRaMessage.java:85)
        at org.eclipse.kura.loRaService.LoRaCommunicatorThread.run(LoRaCommunicatorThread.java:49)
        at java.lang.Thread.run(Thread.java:745)


I dont know why my bundle is trying to do the above cast. I dont know from where he is getting the class: com.sun.crypto.provider.AESCipher$General

Here is my manifest:

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


Thanks !

[Updated on: Tue, 18 April 2017 12:11] by Moderator

Re: ClassCastException when using third lib javax.crypto [message #1759882 is a reply to message #1759810] Wed, 19 April 2017 10:07 Go to previous message
Eclipse UserFriend
Hello,

There is no need to embed the javax-crypto jar in your bundle. The packages are already available in the container. Just import the javax.crypto packages you need in your bundle's manifest. I believe the same question was also asked and answered here [1].

[1] http://stackoverflow.com/questions/43491542/classcastexception-when-using-javax-crypto

Thanks,
--Dave
Previous Topic:Raspberry pi zero w
Next Topic:About new Kura GitFlow https://github.com/eclipse/kura/wiki/New-Kura-Git-Workflow
Goto Forum:
  


Current Time: Wed Jul 09 12:49:31 EDT 2025

Powered by FUDForum. Page generated in 0.03447 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top