3 Replies Latest reply on Dec 11, 2014 10:38 AM by Jose E. Chavez

    Static module is unable to use classes defined in my EAR

    Jose E. Chavez Newbie

      I have an EAR with an internal JAR dependency (model.jar) located in app.ear/lib/model.jar.

      This JAR file contains serializable objects I wish to use over JMS.


      I've defined a JCA static module for our FioranoMQ and succesfully installed it on Wildfly, placed under wildfly/modules/com/fiorano/mq/ra/main.


      Now, on an MDB, when I try to do objectMessage.getObject(), I expect to get back a serializable LoginRequest object. But I get this exception:


      2014-12-10 16:38:52,797 ERROR [com.company.wildfly.ejb.TestQueueMessageBean] (default-threads - 2) javax.jms.MessageFormatException: java.lang.ClassNotFoundException: com.company.model.auth.query.LoginRequest from [Module "com.fiorano.mq.ra:main" from local module loader @108c4c35 (finder: local module finder @4ccabbaa (roots: \wildfly-8.1.0.Final\modules,\wildfly-8.1.0.Final\modules\system\layers\base))]


      Any idea what I may be doing wrong?

        • 1. Re: Static module is unable to use classes defined in my EAR
          Jay SenSharma Master

          The Error indicates that  from module "com.fiorano.mq.ra"  (which is a static module)   the class "com.company.model.auth.query.LoginRequest" is not accessible/visible.    Which is correct and normal behaviour according to JBoss modularized classloading design,   because you have placed the "com.company.model.auth.query.LoginRequest" class inside  a JAR present inside the "app.ear/lib/model.jar".   "app.ear"  is an application means it is a Dynamic module.


          The Dynamic module (like deployments)  can be dependent on the static modules (like com.fiorano.mq.ra)  but reverse is not allowed by default.   Means   the static modules (com.fiorano.mq.ra) will not have access to the resources present inside the dynamic modules (app.ear).


          So you should put the "model.jar" also inside the "com.fiorano.mq.ra" module.

          • 2. Re: Re: Static module is unable to use classes defined in my EAR
            Jose E. Chavez Newbie

            Thanks Jay. But the question then is, how does a module like org.hornetq.ra then handle dependencies such as these?

            Obviously, if I am using ObjectMessage with HornetQ, then how does HornetQ know of the objects it has when I say objectMessage.getObject()?

            • 3. Re: Static module is unable to use classes defined in my EAR
              Jose E. Chavez Newbie

              I solved the issue by adding the model.jar to the JCA adapter's module.xml.


              I also had to add a module dependency of sun.jdk, after getting the following exception. I saw that HornetQ also has this dependency in it's module.


              14:13:24,078 ERROR [org.jboss.as.ejb3.invocation] (default task-24) JBAS014134: EJB Invocation failed on component AuthenticatorEJB for method public com.company.fw.gateway.persistence.jpa.user.User com.company.fw.gateway.model.messaging.jms.auth.Authenticator.authenticate(java.lang.String,java.lang.String): javax.ejb.EJBException: JBAS014580: Unexpected Error

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]


              Caused by: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder

                  at com.company.utils.security.SecurityUtils.digestString(SecurityUtils.java:26) [staroption-util.jar:]

                  at com.company.model.auth.query.LoginRequest.<init>(LoginRequest.java:42) [staroption-model.jar:]

                  at com.company.fw.gateway.model.messaging.jms.auth.Authenticator.authenticate(Authenticator.java:57) [:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_20]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_20]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_20]

                  at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_20]

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

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

                  at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

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

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

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

                  at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) [wildfly-weld-8.2.0.Final.jar:8.2.0.Final]



              But I am just a little disturbed by this. Would it be ideal to create another custom module, and add in my application dependencies (data transfer objects) to expose to FioranoMQ JMS JCA adapter?

              What if I have several applications running in the app server, each with its own set of classes that I would want to serialize over FioranoMQ JMS?