2 Replies Latest reply on Oct 27, 2015 2:38 AM by Davide Crudo

    rest-crypto library and MessagingException problem

    Davide Crudo Newbie

      Dear All,

       

      I believe i'm missing something here, but after spending over a week on the issue i don't seem to come up with

      more ideas...

       

      Using the rest-crypto library and the sample provided on the WildFly documentation, i can successfully create an

      EnvelopedOutput and submit it to the Rest Service. On the Rest Service side the method is called but then it fails

      with the message below when executing the following:

       

       

      UserImpl user = input.getEntity(privateKey, certificate);

       

       

      Caused by: java.lang.NoClassDefFoundError: javax/mail/MessagingException

          at org.jboss.resteasy.security.smime.EnvelopedInputImpl.getEntity(EnvelopedInputImpl.java:156)

          at org.jboss.resteasy.security.smime.EnvelopedInputImpl.getEntity(EnvelopedInputImpl.java:123)

          at com.test.ws.server.WsLoginServerImpl.Cryptologin(WsLoginServerImpl.java:85)

          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.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)

          at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)

          at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)

          at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)

          at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)

          at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

          at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

          at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)

          ... 74 more

      Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException from [Module "org.bouncycastle:main" from local module loader @6ebc05a6 (finder: local module finder @6e6c3152 (roots: C:\Wildfly9\modules,C:\Wildfly9\modules\system\layers\base))]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

          ... 106 more

       

      I've checked and the jar for the MessagingException is in fact in the javax.mail jar and the jar is of course included in jboss.

       

       

      I've even tried to add a java mail jar file into the webservice project, just in case, but it didn't get solved. I've tried to replace the javamail

      version and use 1.5.1 instead of 1.5.3 as included in wildfly 9.0.1 but no changes.

       

      One more thing: I know that the rest-crypto library is included in jboss, but for some reason is not picked up in the buildpath of eclipse, therefore

      i've added a rest-crypto.jar to the project. Could this be the issue?

       

      Any hint would be greatly appreciated.


      Thanks a lot.

      Dave.

        • 1. Re: rest-crypto library and MessagingException problem
          Tomaz Cerar Master

          This was fixed in WildFly 9. so best thing to do is to upgrade.

           

          https://issues.jboss.org/browse/WFLY-4621

          • 2. Re: rest-crypto library and MessagingException problem
            Davide Crudo Newbie

            Dear Tomaz,

             

            thanks a lot! This solved the issue. I didn't expect this to come from Wildfly, especially since i've been using the latest 9.0.1 Final... but indeed

            the bugwas still there.

             

            I've applied the changes manually to the configuration files as per tracker WFLY-4621 and at the same time i had to replace the rest-crypto library (3.0.11 in 9.0.1 final) with the

            newer 3.0.13. this last change because there is an additional bug in Resteasy; in fact the Doc for rest manual version 3.0.11 says:

             

             

            @Path("encrypted")

            @POST

            public void postEncrypted(EnvelopedInput<Customer> input)

            {

               PrivateKey privateKey = ...;

               X509Certificate certificate = ...;

               Customer cust = input.getEntity(privateKey, certificate);

            }

             

            And one of the parameters is "certificate" but when executed on the server, it says there is no method accepting "(Key, String)". This seems related to rest missing

            to identify the certificate properly and/or missing the method ("Key, Certificate"). Updating the rest-crypto to 3.0.13 solved the issue. Hopefully this doesn't break anything else...

             

            Thanks again for the right direction!

            Dave