5 Replies Latest reply on Jul 21, 2010 10:37 PM by shane lee

    Configuring jms in components.xml for embedded jboss

    Colin Johnston Newbie

      Seam 2.0.2SP1


      Project generated with seam-gen.


      Add jms.jar to eclipse project classpath


      Added a business interface and stateless bean:


      @Stateless
      @Name("testFooQueueSender")
      public class TestQueueSenderSvc implements TestQueueSender {
      
           @In
           private QueueSender testQueueSender;
           
           @In
           private QueueSession queueSession;
      
           public void sendTestMessage() {
                try {
                     testQueueSender.send(queueSession.createTextMessage("this is my test message"));
                } catch (Exception ex) {
                     throw new RuntimeException(ex);
                }
           }
      }
      



      in components.xml:


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:drools="http://jboss.com/products/seam/drools"
                  xmlns:bpm="http://jboss.com/products/seam/bpm"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:jms="http://jboss.com/products/seam/jms"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                       http://jboss.com/products/seam/jms http://jboss.com/products/seam/jms-2.0.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
         <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
           
         <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>
          
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/testjmsEntityManagerFactory"/>                          
      
         <drools:rule-base name="securityRules">
             <drools:rule-files>
                 <value>/security.drl</value>
             </drools:rule-files>
         </drools:rule-base>
      
         <security:identity security-rules="#{securityRules}" authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
         
         <event type="org.jboss.seam.security.notLoggedIn">
             <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
             <action execute="#{redirect.returnToCapturedView}"/>
         </event>
         
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
              
         <jms:managed-queue-sender name="testQueueSender" 
                          auto-create="true" 
                          queue-jndi-name="queue/testQueue"/>
                          
      </components>
      



      seam can't initialize testQueueSender (running with jboss embedded by running the test target of build.xml)



      javax.ejb.EJBException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: testQueueSender
           at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
           at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:193)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:64)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:166)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:249)
           at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
           at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:86)
           at $Proxy62.sendTestMessage(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
           at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
           at org.javassist.tmp.java.lang.Object_$$_javassist_0.sendTestMessage(Object_$$_javassist_0.java)
           at com.innovativeinfo.jmstest.test.TestQueueSenderTest$1.testComponents(TestQueueSenderTest.java:18)
           at org.jboss.seam.mock.BaseSeamTest$ComponentTest.run(BaseSeamTest.java:169)
           at com.innovativeinfo.jmstest.test.TestQueueSenderTest.testQueueSenderTest(TestQueueSenderTest.java:13)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
           at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
           at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
           at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
           at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
           at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
           at org.testng.TestRunner.runWorkers(TestRunner.java:678)
           at org.testng.TestRunner.privateRun(TestRunner.java:624)
           at org.testng.TestRunner.run(TestRunner.java:495)
           at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
           at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
           at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
           at org.testng.SuiteRunner.run(SuiteRunner.java:190)
           at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
           at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
           at org.testng.TestNG.run(TestNG.java:699)
           at org.testng.TestNG.privateMain(TestNG.java:824)
           at org.testng.TestNG.main(TestNG.java:802)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: testQueueSender
           at org.jboss.seam.Component.newInstance(Component.java:1986)
           at org.jboss.seam.Component.getInstance(Component.java:1876)
           at org.jboss.seam.Component.getInstance(Component.java:1843)
           at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2192)
           at org.jboss.seam.Component.getValueToInject(Component.java:2144)
           at org.jboss.seam.Component.injectAttributes(Component.java:1601)
           at org.jboss.seam.Component.inject(Component.java:1419)
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
           at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
           ... 54 more
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.jms.queueSession
           at org.jboss.seam.Component.newInstance(Component.java:1986)
           at org.jboss.seam.Component.getInstance(Component.java:1876)
           at org.jboss.seam.Component.getInstance(Component.java:1843)
           at org.jboss.seam.Component.getInstance(Component.java:1822)
           at org.jboss.seam.Component.getInstance(Component.java:1817)
           at org.jboss.seam.jms.QueueSession.instance(QueueSession.java:55)
           at org.jboss.seam.jms.ManagedQueueSender.create(ManagedQueueSender.java:51)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2092)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2015)
           at org.jboss.seam.Component.newInstance(Component.java:1976)
           ... 82 more
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.jms.queueConnection
           at org.jboss.seam.Component.newInstance(Component.java:1986)
           at org.jboss.seam.Component.getInstance(Component.java:1876)
           at org.jboss.seam.Component.getInstance(Component.java:1843)
           at org.jboss.seam.Component.getInstance(Component.java:1822)
           at org.jboss.seam.Component.getInstance(Component.java:1817)
           at org.jboss.seam.jms.QueueConnection.instance(QueueConnection.java:75)
           at org.jboss.seam.jms.QueueSession.create(QueueSession.java:38)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2092)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2015)
           at org.jboss.seam.Component.newInstance(Component.java:1976)
           ... 97 more
      Caused by: java.lang.RuntimeException: exception invoking: init
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:135)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2092)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2015)
           at org.jboss.seam.Component.newInstance(Component.java:1976)
           ... 112 more
      Caused by: javax.naming.NameNotFoundException: UIL2ConnectionFactory not bound
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:542)
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:550)
           at org.jnp.server.NamingServer.getObject(NamingServer.java:556)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:669)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at org.jboss.seam.jms.QueueConnection.getQueueConnectionFactory(QueueConnection.java:64)
           at org.jboss.seam.jms.QueueConnection.init(QueueConnection.java:51)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
           ... 115 more
      
      


      it seems as though the component UIL2ConnectionFactory is not available.


      do I need to add a queue connection definition to components.xml?


      <jms:queue-connection auto-create="true" queue-connection-factory-jndi-name="java:/XAConnectionFactory" />
      



      if so, what is the correct value for queue-connection-factory-jndi-name? Is it even possible to run this within jboss embedded?


      Thanks



        • 1. Re: Configuring jms in components.xml for embedded jboss
          Pete Muir Master

          Take a look at src/test/integration in the seam distribution for an example of integration tests using JMS

          • 2. Re: Configuring jms in components.xml for embedded jboss
            Colin Johnston Newbie

            for those interested, components.xml should contain (for example):


               <jms:topic-connection topic-connection-factory-jndi-name="/ConnectionFactory" />
               <jms:queue-connection queue-connection-factory-jndi-name="/ConnectionFactory" />
            
               <jms:managed-topic-publisher name="testPublisher"
                                            auto-create="true" 
                                            topic-jndi-name="/topic/testTopic" />
                                              
               <jms:managed-queue-sender name="testSender"
                                         auto-create="true"
                                         queue-jndi-name="/queue/testQueue" />
            
            



            and a file named test-destinations-service.xml should exist in /resources with mbean definitions to create/configure the corresponding the topics and queues:


            <server>
                 <mbean code="org.jboss.mq.server.jmx.Topic"
                         name="jboss.mq.destination:service=Topic,name=testTopic">
                      <depends optional-attribute-name="ServerPeer">
                           jboss.messaging:service=ServerPeer
                      </depends>
                      <depends>jboss.messaging:service=PostOffice</depends>
                 </mbean>
                 
                 <mbean code="org.jboss.mq.server.jmx.Queue"
                         name="jboss.mq.destination:service=Queue,name=testQueue">
                      <depends optional-attribute-name="ServerPeer">
                           jboss.messaging:service=ServerPeer
                      </depends>
                      <depends>jboss.messaging:service=PostOffice</depends>
                 </mbean>
            </server>
            

            • 3. Re: Configuring jms in components.xml for embedded jboss
              Thomas Jonsson Newbie

              Hi!


              My integration tests is taking long time to execute since there are jms related errors (can't connect) javax.naming.NameNotFoundException: chatroomTopic not bound. I can live with that, but as the application has grown the tests are taking all the heap memory resulting in test failures so now I have to resolve this issue since I'm pretty sure that the jms issue is the problem (to increase the memory doesn't help and is not a solution). I have looked at the chatRoomTopic example and done exactly the same thing, but still it doesn't work. My project is Maven based where one ejb module (core) passes, but I have a problem in this project as well: java.lang.RuntimeException: Failed to download and/or install client side AOP stack. The other module is dependent of core, and in this module the chatRoomTopic topic is connected ten times before it gives up, but then there is not enough memory left. I tried to change the number of reconnecs without success. Any ideas?


              Does you guys have any ideas what is wrong? I have tried and tried and tried. Followed examples in src/test/integration and the chatRoom example.


              Best regards,
              Thomas

              • 4. Re: Configuring jms in components.xml for embedded jboss
                Thomas Jonsson Newbie

                The memory problem resolved. Had to set the -Xmx flag in maven surefire plugin configuration. But the JMS problem is still there. It's annoying and increases the test time.

                • 5. Re: Configuring jms in components.xml for embedded jboss
                  shane lee Newbie

                  In your MessageProducer/QueueSender class make sure and close the connections too.



                  @Name("testDispatcher")
                  public class TestDispatcher {
                      
                      @In private QueueSender testQueueSender;   
                      @In private QueueSession queueSession;
                  
                      public void publish(String message) 
                      {
                         try
                         {
                             testQueueSender.send(queueSession.createTextMessage(message));
                         } 
                         catch (Exception ex)
                         {
                            throw new RuntimeException(ex);
                         } finally{
                             try {
                                 if(testQueueSender != null){
                                      testQueueSender.close();
                                 }
                                 if(queueSession != null ){
                                     queueSession.close();
                                     
                                 }
                             }catch (JMSException e) {
                                 // TODO Auto-generated catch block
                                 e.printStackTrace();
                             }
                             }
                         }
                      }