Discussion:
[jboss-user] [JBoss Messaging] - Spring JMS error with JBoss 7.1.1-Final
Marcio B.
2012-04-14 00:31:54 UTC
Permalink
Marcio B. [https://community.jboss.org/people/romarcio] created the discussion

"Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/730037#730037

--------------------------------------------------------------
Hello!
I am trying to configure a JMS Listener with Spring 3.1 in JBoss 7.1.1-Final.
But this exception is thrown:

21:05:20,184 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC00001: Failed to start service jboss.deployment.unit."jms-receiver.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jms-receiver.war".PARSE: Failed to process phase PARSE of deployment "jms-receiver.war"
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          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: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011666: Could not parse file C:\jboss-as-7.1.1.Final\standalone\tmp\vfs\temp22a1673201a833b9\jms-receiver.war-1a83767da3f83ba\WEB-INF\spring-jms.xml
          at org.jboss.as.messaging.deployment.MessagingXmlParsingDeploymentUnitProcessor.deploy(MessagingXmlParsingDeploymentUnitProcessor.java:76)
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
          ... 5 more
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011666: Could not parse file C:\jboss-as-7.1.1.Final\standalone\tmp\vfs\temp22a1673201a833b9\jms-receiver.war-1a83767da3f83ba\WEB-INF\spring-jms.xml
          at org.jboss.as.messaging.deployment.MessagingXmlParsingDeploymentUnitProcessor.deploy(MessagingXmlParsingDeploymentUnitProcessor.java:73)
          ... 6 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]
Message: Unexpected element '{ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans}beans'
          at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
          at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
          at org.jboss.as.messaging.deployment.MessagingXmlParsingDeploymentUnitProcessor.deploy(MessagingXmlParsingDeploymentUnitProcessor.java:67)
          ... 6 more


21:05:20,198 INFO  [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "jms-receiver.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"jms-receiver.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"jms-receiver.war\".PARSE: Failed to process phase PARSE of deployment \"jms-receiver.war\""}}
21:05:20,351 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-11) JBAS015877: Stopped deployment jms-receiver.war in 153ms
21:05:20,352 INFO  [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."jms-receiver.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jms-receiver.war".PARSE: Failed to process phase PARSE of deployment "jms-receiver.war"


File spring-jms.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans"
       xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
                <prop key="java.naming.provider.url">remote://localhost:4447</prop>
                <prop key="java.naming.security.principal">user</prop>
                <prop key="java.naming.security.credentials">pass</prop>
            </props>
        </property>
    </bean>


    <bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="jms/RemoteConnectionFactory"/>
        <property name="jndiTemplate" ref="jndiTemplate"/>
    </bean>


    <bean id="secureConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="queueConnectionFactory"/>
        <property name="username" value="user"/>
        <property name="password" value="pass"/>
    </bean>


    <bean id="queueName" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="jms/queue/test"/>
        <property name="jndiTemplate" ref="jndiTemplate"/>
    </bean>


    <bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
        <constructor-arg>
            <bean class="com.tecnoil.consumer.jms.JMSConsumer"/>
        </constructor-arg>
        <property name="messageConverter">
            <null/>
        </property>
    </bean>


    <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="secureConnectionFactory"/>
        <property name="destination" ref="queueName"/>
        <property name="sessionAcknowledgeModeName" value="AUTO_ACKNOWLEDGE"/>
        <property name="messageListener" ref="messageListener"/>
        <property name="receiveTimeout" value="1000"/>
    </bean>
</beans>

What is the solution?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/730037#730037]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Maqsood Shahzad
2012-11-24 09:54:54 UTC
Permalink
Maqsood Shahzad [https://community.jboss.org/people/maqsood.shahzad] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/778174#778174

--------------------------------------------------------------
Hi,

I am facing the same problem on AS 7.1.1. Any help would be greatly appreciated.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/778174#778174]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Marcio B.
2012-11-24 12:58:09 UTC
Permalink
Marcio B. [https://community.jboss.org/people/romarcio] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/778178#778178

--------------------------------------------------------------
Unfortunately I didn't get to resolve it with XML configuration. It was necessary to configure the JMS via programmatic configuration instead of XML configuration.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/778178#778178]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Maqsood Shahzad
2012-11-24 14:02:15 UTC
Permalink
Maqsood Shahzad [https://community.jboss.org/people/maqsood.shahzad] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/778181#778181

--------------------------------------------------------------
Would appreciate if you could share your solution.

Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/778181#778181]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Marcio B.
2012-11-24 21:33:44 UTC
Permalink
Marcio B. [https://community.jboss.org/people/romarcio] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/778206#778206

--------------------------------------------------------------
Sorry, but I don't have the source with me.

Look here some examples, but unfortunately nat are about JMS:
http://static.springsource.org/spring/docs/3.0.x/reference/beans.html#beans-java-instantiating-container-register http://static.springsource.org/spring/docs/3.0.x/reference/beans.html#beans-java-instantiating-container-register
http://mballem.wordpress.com/2012/11/01/spring-framework-3-100-livre-de-configuracao-por-xml/ http://mballem.wordpress.com/2012/11/01/spring-framework-3-100-livre-de-configuracao-por-xml/

You will need to follow this model of configuration, however it of course, for configuring JMS. Use the classes of jms beans from your XML to create your beans programmatically.

Sorry by my english, I am still learning .
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/778206#778206]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Alain Brazeau
2012-12-03 16:24:09 UTC
Permalink
Alain Brazeau [https://community.jboss.org/people/abrazeau] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/779674#779674

--------------------------------------------------------------
This is a simple problem to resolve.  Just rename the problematic Spring XML file so that it doesn't end with "-jms.xml".

I examined some of the JBoss source code and noticed that it attempts to parse any "*-jms.xml" file.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779674#779674]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Marcio B.
2012-12-03 16:38:57 UTC
Permalink
Marcio B. [https://community.jboss.org/people/romarcio] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/779682#779682

--------------------------------------------------------------
When I had problems, I tried to do that and not resolved. The problem seems to be in the XML tags.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779682#779682]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
nuwan.wp wickramanayaka
2013-07-04 07:13:45 UTC
Permalink
nuwan.wp wickramanayaka [https://community.jboss.org/people/nuwan.wp] created the discussion

"Re: Spring JMS error with JBoss 7.1.1-Final"

To view the discussion, visit: https://community.jboss.org/message/826340#826340

--------------------------------------------------------------
message-queue-config.spring.xml
-------------------------------


<!-- Jndi properies for accessing Jboss 7.1 Hornet Queue -->


          <bean id="jnditemplate" class="org.springframework.jndi.JndiTemplate">
                    <property name="environment">
                              <props>
                                        <prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory
                                        </prop>
                                        <prop key="java.naming.provider.url">remote://${sampleweb.server.ip}:4447</prop>
                                        <prop key="java.naming.security.principal">uanmcts</prop>
                                        <prop key="java.naming.security.credentials">password</prop>
                              </props>
                    </property>
          </bean>


          <!-- Jms connection configurations -->


          <bean id="connectionfactory" class="org.springframework.jndi.JndiObjectFactoryBean">
                    <property name="jndiTemplate" ref="jnditemplate" />
                    <property name="jndiName" value="jms/RemoteConnectionFactory" />
          </bean>


          <!-- Jms queue configurations -->


          <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
                    <property name="jndiTemplate" ref="jnditemplate" />
                    <property name="jndiName" value="jms/queue/mail" />
          </bean>


          <!-- Credentials for accessing jboss queue -->


          <bean id="credentialsconnectionfactory"
                    class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
                    <property name="targetConnectionFactory" ref="connectionfactory" />
                    <property name="username" value="uanmcts" />
                    <property name="password" value="password" />
          </bean>


          <bean id="cachingConnectionFactory"
                    class="org.springframework.jms.connection.CachingConnectionFactory">
                    <property name="targetConnectionFactory" ref="connectionfactory" />
                    <property name="sessionCacheSize" value="1" />
          </bean>


          <!-- Jms template configurations -->


          <bean id="jmstemplate" class="org.springframework.jms.core.JmsTemplate">
                    <property name="connectionFactory" ref="cachingConnectionFactory" />
                    <property name="defaultDestination" ref="destination" />
          </bean>

          <bean id="messageService"
                    class="com.jkcs.uanmcts.core.messaging.service.impl.EmailMessageServiceImpl">
                    <property name="jmsTemplate" ref="jmstemplate" />
          </bean>


          <!-- Jms message Listner configurations -->


          <bean
                    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
                    <property name="connectionFactory" ref="credentialsconnectionfactory" />
                    <property name="destination" ref="destination" />
                    <property name="messageListener" ref="messageService" />
                    <property name="autoStartup" value="true" />
                    <property name="concurrentConsumers" value="5" />
                    <property name="maxConcurrentConsumers" value="10" />
          </bean>


Refer bean 'messageService'
----------------------------


@InternalService
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class EmailMessageServiceImpl implements EmailMessageService {


          private static final Log LOG = LogFactory
                              .getLog(EmailMessageServiceImpl.class);


          @Autowired
          private JmsTemplate jmsTemplate;

          @Autowired
          JKCSMailSender emailSender;

          @Override
          public Boolean sendEmailToQueue(final TemplatedEmailDTO messageDto)
                              throws FrameworkServiceException {

                    Boolean isEmailSent = false;
                    LOG.info("Trying to send email message on queue.");

                    try {

                              getJmsTemplate().send(new MessageCreator() {
                                        public Message createMessage(Session session) throws JMSException {

                                                  ObjectMessage objectMessage = session.createObjectMessage(messageDto);
                                                  objectMessage.setJMSRedelivered(false);
                                                  objectMessage.setJMSExpiration(0); /*Value of 0 indicates that a message will never expire*/
                                                  return objectMessage;
                                        }
                              });
                              isEmailSent = true;
                    LOG.info("Email message has been successfully sent to the queue.");


                    } catch (Exception e) {
                              isEmailSent = false;
                              LOG.info("Email message failed while sending to the queue.");
                    }

                    return isEmailSent;

          }
          @Override
          public void onMessage(Message message) {

                    LOG.info("Email message received from queue [" + message +"]"); 
                    try {

                              if(message!=null)
                              {
                                        message.acknowledge();

                                        if (message instanceof ObjectMessage) {

                                                  ObjectMessage objectMessage = (ObjectMessage) message;
                                                  TemplatedEmailDTO emailDto = (TemplatedEmailDTO) objectMessage.getObject();
                                                  emailSender.send(emailDto);
                                                  LOG.info("Email message has been successfully sent."); 
                                        }
                              }
                              else
                              {
                                        LOG.info("Null email message received.");
                              }
                    } catch (JMSException jmsEx_p) {
                               String errMsg = "An error occurred extracting message"; 
                               LOG.error(errMsg, jmsEx_p); 
                              throw new FrameworkServiceException();
                    }

          }


          public JmsTemplate getJmsTemplate() {
                    return jmsTemplate;
          }


          public void setJmsTemplate(JmsTemplate jmsTemplate) {
                    this.jmsTemplate = jmsTemplate;
          }


}
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/826340#826340]

Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
Loading...