Hi,

It seems to me that this is classloader problem. [1] shows the similar problem when use maven surefire plugin to run the test, and the solution is add
<useSystemClassLoader>true</useSystemClassLoader>  to surefire plugin.

Hopefully it's helpful.
[1]http://www.nabble.com/Test-for-PGP-Decryption-fails-with-Maven-t4228688.html

Best Regards

Freeman

Gordon Dickens wrote:
Hello,

Does anyone have any experience with running a decryption service in ServiceMix using Bouncy Castle? We were able to setup a service that would decrypt a file and run it through unit testing in Eclipse, however, when we run it in ServiceMix we get the following:

org.bouncycastle.openpgp.PGPException: Exception constructing key
java.security.spec.InvalidKeySpecException: Unknown KeySpec type: org.bouncycastle.jce.spec.ElGamalPrivateKeySpec at org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal.engineGeneratePrivate(Unknown Source)
       at java.security.KeyFactory.generatePrivate(KeyFactory.java:316)
at org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey(Unknown Source) at com.myco.services.PGPEncryptionHelper.findSecretKey(PGPEncryptionHelper.java:110) at com.myco.services.PGPEncryptionHelper.decryptFile(PGPEncryptionHelper.java:151) at com.myco.services.FileDecryptor.decryptFile(FileDecryptor.java:103) at com.myco.services.FileDecryptor.onMessageExchange(FileDecryptor.java:66) at org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java:224) at org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:200) at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538) at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490) at org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610) at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:170) at org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167) at org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
       at java.lang.Thread.run(Thread.java:595)

I checked the JAVA_HOME environment variable that ServiceMix is using on startup and it is the correct one (configured with Bouncy Castle v137).

Thoughts, suggestions, any help is appreciated.

Thanks,
Gordon Dickens

Reply via email to