8 Replies Latest reply on Jul 16, 2012 4:41 AM by paulo.ricardo

    jboss 7 ActiveMQ integration - Resource Adapter loading after wars

    paulo.ricardo

      Hello,

      I've been able to successfully configure activemq with jboss7 by reading these threads: https://community.jboss.org/thread/172319 and https://community.jboss.org/message/729908, but I still have a problem.

      I have a .war file that depends on the activemq.rar and only deploys correctly if the activemq.rar is already deployed.
      The problem is that when I need to restart the server, sometimes the activemq.rar hasn't completely deployed yet when the war tries to use the activemq resources. Is there a way to make sure that the war only starts to deploy after the rar has finished deploying?

      If I deploy the activemq.rar and then the several war's that depend on it, it works.

      On server startup I have this error:

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactoryBean' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Error looking up activemq/QueueConnectionFactory, service service jboss.naming.context.java.jboss.activemq.QueueConnectionFactory is not started

                at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.

       

       

        • 1. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
          jaikiran

          Why not package the .rar and the .war into a .ear?

          1 of 1 people found this helpful
          • 2. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
            paulo.ricardo

            That's the solution we are implementing now, but we don't like it very much, because when one of the wars is changed, we have to build a new ear, thus, we are "messing" with more applications other than the one that was changed.

            • 3. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
              jesper.pedersen

              Do you have

               

              Dependencies: deployment.activemq.rar
              

               

              in your .war/META-INF/MANIFEST.MF ? Or a jboss-deployment-structure.xml file ?

              1 of 1 people found this helpful
              • 4. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
                paulo.ricardo

                Hi Jesper

                 

                Now we have the dependencies , thanks

                 

                But when we solved this problem we've faced another one:

                 

                If we add:

                Dependencies: deployment.activemq.rar
                

                to our MANIFEST.MF

                 

                or:

                 

                <module name="deployment.activemq.rar" />
                

                to the  jboss-deployment-structure.xml,

                 

                the war waits until the rar has been deployed (as expected), but then we start to have some ClassNotFoundExceptions. To solve these exceptions we had to copy every single jar from the .war/WEB-INF/lib folder into the rar. This works, but, once again it's not a clean solution because if we add another .war we're gonna have to copy it's lib's into the activemq.rar, and that just doesn't seems a good thing.

                 

                Is there any other way to avoid these ClassNotFoundExceptions?

                 

                Cheers

                • 5. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
                  jesper.pedersen

                  You are not providing a lot of information - what ClassNotFoundExceptions, are you using classloaders in your application, ...

                   

                  One thing is for sure - copying your libraries into the .rar is wrong.

                  • 6. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
                    paulo.ricardo

                    Hello Jesper

                     

                    I'll try to give you some more details.

                     

                    First of all, I've deployed the activemq.rar and after that my .war without the "Dependencies: deployment.activemq.rar" and since I've manually deployed each one in order it worked just fine.

                    Then, in order to force that the .war waited for the deployment of the activemq.rar, I've added the "Dependencies: deployment.activemq.rar" and got this stacktrace:

                     

                     

                    nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.10.Final.jar:]
                              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.10.Final.jar:]
                              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
                              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
                    Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect
                              at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.hasAspectAnnotation(AbstractAspectJAdvisorFactory.java:119) [spring-aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.isAspect(AbstractAspectJAdvisorFactory.java:115) [spring-aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.isInfrastructureClass(AnnotationAwareAspectJAutoProxyCreator.java:100) [spring-aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278) [spring-aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:880) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:852) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
                              ... 18 more
                    Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Aspect from [Module "deployment.activemq.rar:main" from Service Module Loader]
                              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
                              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
                              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
                              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
                              ... 25 more
                    
                    

                     

                     

                    So I copied the aspectj .jar to the activemq.rar. This happened to every .jar that was on my .war WEB-INF folder.

                     

                     

                    I don't have any costumized classloader.

                     

                    Hope this is enough info.

                     

                    Thanks for your help.

                    • 7. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
                      paulo.ricardo

                      Let me just add that, although the exception says:

                      Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Aspect from [Module "deployment.activemq.rar:main" from Service Module Loader] 
                      
                      
                      
                      

                      it occurs when I'm deploying the .war (with the activemq.rar already deployed).

                      • 8. Re: jboss 7 ActiveMQ integration - Resource Adapter loading after wars
                        paulo.ricardo

                        Hello again,

                         

                        I'm not beeing able to make a test that shows clearly what's causing the problem, but I think that it has something to do with the using of aspects in my application.

                        I'm wandering if anyone has had some similar problem.

                         

                        Cheers

                        Paulo Ribeiro