Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 16:08 Go to next message
Sabrina anirbas is currently offline Sabrina anirbasFriend
Messages: 45
Registered: April 2015
Member
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 16:11]

Report message to a moderator

Re: ClassCastException when using third lib javax.crypto [message #1759882 is a reply to message #1759810] Wed, 19 April 2017 14:07 Go to previous message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
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: Thu Apr 18 16:23:46 GMT 2024

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

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

Back to the top