Announcement Announcement Module
No announcement yet.
Problem running the JMS Examples Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem running the JMS Examples


    I have created a plugin project in eclipse and added the lib from Spring Integration. I have then added to java files in the org.springframework.integration.samples.jms package to my project in tried running the GatewayDemo.

    I get then get the following error :

    6-feb-2009 9:39:15 ationContext prepareRefresh
    INFO: Refreshing plicationContext@13a328f: display name [ plicationContext@13a328f]; startup date [Fri Feb 06 09:39:15 CET 2009]; root of context hierarchy
    6-feb-2009 9:39:15 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [common.xml]
    6-feb-2009 9:39:15 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [inboundGateway.xml]
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 20 in XML document from class path resource [inboundGateway.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jms:inbound-gateway'.
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR
    at BeanDefinitionReader.loadBeanDefinitions(AbstractB
    at licationContext.loadBeanDefinitions(AbstractXmlApp
    at licationContext.loadBeanDefinitions(AbstractXmlApp
    at hableApplicationContext.refreshBeanFactory(Abstrac
    at ationContext.obtainFreshBeanFactory(AbstractApplic
    at ationContext.refresh(AbstractApplicationContext.ja va:352)
    at plicationContext.<init>(ClassPathXmlApplicationCon
    at plicationContext.<init>(ClassPathXmlApplicationCon
    at org.springframework.integration.samples.jms.Gatewa yDemo.main(
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jms:inbound-gateway'.
    at erWrapper.createSAXParseException(Unknown Source)
    at erWrapper.error(Unknown Source)
    at porter.reportError(Unknown Source)
    at porter.reportError(Unknown Source)
    at maValidator$XSIErrorReporter.reportError(Unknown Source)
    at maValidator.reportSchemaError(Unknown Source)
    at maValidator.handleStartElement(Unknown Source)
    at maValidator.emptyElement(Unknown Source)
    at entScannerImpl.scanStartElement(Unknown Source)
    at tFragmentScannerImpl$FragmentContentDispatcher.dis patch(Unknown Source)
    at tFragmentScannerImpl.scanDocument(Unknown Source)
    at nfiguration.parse(Unknown Source)
    at nfiguration.parse(Unknown Source)
    at er.parse(Unknown Source)
    at er.parse(Unknown Source)
    at ilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.loadDocument( 75)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio
    ... 11 more

    So cleary the jms:inbound-gateway tag is unknown.
    However I have tab completion when editing the xml file and it suggestes the tag in question.
    What I'm a doing wrong ?

  • #2
    u need to download activemq from apache then start it up and create the 2 queues specified in the xml file


    • #3
      by default eclipse (like most other IDEs) uses the schema found at the url defined in schemaLocations for code completion. At runtime Spring uses the schema from the jar file. If you just added the spring integration jar, but not the adapters and jms jar, spring will not be able to find the schema at runtime (and the parser will complain during parsing).

      Check the .classpath of the sample project, or look at the pom.xml or ivy.xml to see the exact dependencies. That should help you figure out what is missing. It is recommended to set your XML Catalog in eclipse to look at the schema in the jar, so that you are not surprised by differences between the online schema and the one in the jar.


      • #4
        iwein thanks, this was indeed the problem.

        A follow up question :
        I'm using 10 input queues REQ0..REQ9 and then output queus RSP0..RSP9.
        However the repy to a message from REQx has to be posted on RSPx.

        Can I use the jms:inbound-gateway to solve this problem using a custom a header mapper to map to source to the destination? Because I've read this is a blocking call (sendAndReceive) and I would like to use ThreadPools to execute some logic on the incoming data and with a blocking call this doesn't seem possible because blocking would indicate on single thread of execution.

        Or should I use jms:inbound-channel-adapter together with jms:outbound-channel-adapter. But then I have to use a router to send to replies to the right jms:outbound-channel-adapter, whichs seems unneccesary, because this could have been done by putting the destination in the message on receipt using the same custon headermapper as in the previous section.

        Any ideas, suggestion ?


        • #5
          I do not have time to look into this right now, but there might be some features missing from the JMS adapters that are available in Spring's jms support, for example the destination resolver. If you can dig a little into this and expose what's missing please create a feature request for it in JIRA with your code sample.


          • #6
            A reply-destination for the jms:inbound-gateway ?

            If I understand the documentation correctly the folowing config file :
            <jms:outbound-gateway id="jmsin"

            Lets Spring send a message to requestQueue and then waits for a matching response on ReplyQueue.

            I would like to know if a similar thing exsist for an inbound gateway.
            Spring reads as message from requestQueue gives it to demoChannel and let the demoBean do some logic and then send the response back to the replyQueue.
            The config could look like this.

            <jms:inbound-gateway id="jmsin"

            <channel id="demoChannel"/>

            <service-activator input-channel="demoChannel" ref="demoBean"/>

            Is this possible?


            • #7
              The inbound-gateway should send any reply to the destination specified in the request JMS Message's 'replyTo' property.


              • #8
                I have tried to use the ReplyTo property in the following code:

                import javax.jms.ConnectionFactory;
                import javax.jms.JMSException;
                import javax.jms.Message;
                import javax.jms.Queue;
                import javax.jms.Session;

                import plicationContext;
                import org.springframework.jms.core.JmsTemplate;
                import org.springframework.jms.core.JmsTemplate102;
                import org.springframework.jms.core.MessageCreator;

                public class JmsQueueSender {

                private JmsTemplate jmsTemplate;

                private Queue queue;

                public void setConnectionFactory(ConnectionFactory cf) {
                jmsTemplate = new JmsTemplate102(cf, false);

                public void setQueue(Queue q) {
                queue = q;

                public void simpleSend() {
                this.jmsTemplate.send(this.queue, new MessageCreator() {
                public Message createMessage(Session session) throws JMSException {
                Message message = session.createTextMessage("hello spring world");
                message.setJMSReplyTo(new com.sun.messaging.Queue("queue.demo"));
                return message;

                public static void main(String args[])
                ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("sender.xml");
                JmsQueueSender sender = new JmsQueueSender();
                sender.setConnectionFactory((ConnectionFactory)con text.getBean("connectionFactory"));


                I then run the GateWayDemo :

                import plicationContext;

                * Bootstrap for starting the JMS Gateways.
                * @author Mark Fisher
                public class GatewayDemo {

                private final static String[] configFiles = {
                "common.xml", "inboundGateway.xml"

                public static void main(String[] args) {
                new ClassPathXmlApplicationContext(configFiles, GatewayDemo.class);


                But I modified the connectionfactory to use Open MQ:

                <bean id="connectionFactory" class="com.sun.messaging.QueueConnectionFactory">

                <bean id="requestQueue" class="com.sun.messaging.Queue">
                <constructor-arg value="queue.demo"/>

                <bean id="replyQueue" class="com.sun.messaging.Queue">
                <constructor-arg value="queue.reply"/>

                During execution I get the following error:

                at com.sun.messaging.jmq.jmsclient.MessageProducerImp l.send(
                at org.springframework.integration.jms.ChannelPublish ingJmsMessageListener.onMessage(ChannelPublishingJ
                at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doInvokeListener(AbstractMessageLi
                at org.springframework.jms.listener.AbstractMessageLi stenerContainer.invokeListener(AbstractMessageList
                at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doExecuteListener(AbstractMessageL
                at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.doReceiveAndExecute(Abstrac
                at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.receiveAndExecute(AbstractP
                at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.invokeL istener(
                at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.execute OngoingLoop( 74)
                at org.springframework.jms.listener.DefaultMessageLis tenerContainer$

                I'm pretty sure this will also occur with Active MQ. I can provided the full project if you want. Can anybody explain to me why this doesn't work?


                • #9
                  Please use the code tags.

                  Attaching the full project will be helpful too.