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

  • Problem running the JMS Examples

    Dear,

    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 org.springframework.context.support.AbstractApplic ationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlAp plicationContext@13a328f: display name [org.springframework.context.support.ClassPathXmlAp 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 nReader.java:404)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:342)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:310)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:109)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:80)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:123)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:422)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:197)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:172)
    at org.springframework.integration.samples.jms.Gatewa yDemo.main(GatewayDemo.java:34)
    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 com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator$XSIErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.reportSchemaError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.handleStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDispatcher.dis patch(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.loadDocument(DefaultDocumentLoader.java: 75)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:396)
    ... 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

    Comment


    • #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.

      Comment


      • #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 ?

        Comment


        • #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.

          Comment


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

            If I understand the documentation correctly the folowing config file :
            <jms:outbound-gateway id="jmsin"
            reply-destination="replyQueue"
            request-destination="requestQueue"
            request-channel="demoChannel"/>


            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"
            reply-destination="replyQueue"
            request-destination="requestQueue"
            request-channel="demoChannel"/>

            <channel id="demoChannel"/>

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

            Is this possible?

            Comment


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

              Comment


              • #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 org.springframework.context.support.ClassPathXmlAp 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"));
                sender.setQueue((Queue)context.getBean("queue"));
                sender.simpleSend();

                }
                }


                I then run the GateWayDemo :

                import org.springframework.context.support.ClassPathXmlAp 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>


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

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

                During execution I get the following error:

                java.lang.UnsupportedOperationException
                at com.sun.messaging.jmq.jmsclient.MessageProducerImp l.send(MessageProducerImpl.java:730)
                at org.springframework.integration.jms.ChannelPublish ingJmsMessageListener.onMessage(ChannelPublishingJ msMessageListener.java:160)
                at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doInvokeListener(AbstractMessageLi stenerContainer.java:518)
                at org.springframework.jms.listener.AbstractMessageLi stenerContainer.invokeListener(AbstractMessageList enerContainer.java:479)
                at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doExecuteListener(AbstractMessageL istenerContainer.java:451)
                at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.doReceiveAndExecute(Abstrac tPollingMessageListenerContainer.java:323)
                at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.receiveAndExecute(AbstractP ollingMessageListenerContainer.java:261)
                at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.invokeL istener(DefaultMessageListenerContainer.java:982)
                at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.execute OngoingLoop(DefaultMessageListenerContainer.java:9 74)
                at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.run(Def aultMessageListenerContainer.java:876)
                at java.lang.Thread.run(Thread.java:636)

                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?

                Comment


                • #9
                  Please use the code tags.

                  Attaching the full project will be helpful too.

                  Comment

                  Working...
                  X