Announcement Announcement Module
Collapse
No announcement yet.
MessageConverter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessageConverter

    I have the following config in my xml.I can c that the ActiveMQ queue has received the message but when I open to c the message it shows me the follwing error.How should I configure the messageconverter??Have I congigured it right??
    xml
    Code:
    <jms:outbound-gateway id="jmsGateway"
                          jms-queue="DemoQueue"
                          request-channel="sendChannel"
                          reply-channel="jmsReplyChannel" connection-factory="connectionFactory" message-converter="messageConverter"/>
        <beans:bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
    		<beans:property name="targetConnectionFactory">
    			<beans:bean class="org.apache.activemq.ActiveMQConnectionFactory">
    				<beans:property name="brokerURL" value="tcp://localhost:61616"/>		
    			</beans:bean>
    		</beans:property>
    	</beans:bean>
    	
    <beans:bean id="messageConverter" class="org.springframework.jms.support.converter.SimpleMessageConverter"/> 
    	
    <beans:bean id="DemoQueue" class="org.apache.activemq.command.ActiveMQQueue">
    		<beans:constructor-arg value="queue.demo" index="0"/>
    	</beans:bean>
     <stream:stdout-channel-adapter id="jmsReplyChannel" append-newline="true"/>
    ErrorMessage:
    Code:
    HTTP ERROR: 500
    
    javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.IOException: org.springframework.integration.message.GenericMessage
    RequestURI=/admin/message.jsp
    
    javax.el.ELException: javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.IOException: org.springframework.integration.message.GenericMessage
    	at javax.el.BeanELResolver.getValue(BeanELResolver.java:266)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
    	at com.sun.el.parser.AstValue.getValue(AstValue.java:138)
    	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
    	at org.apache.jasper.runtime.PageContextImpl.evaluateExpression(PageContextImpl.java:984)
    	at org.apache.jsp.message_jsp._jspx_meth_c_out_0(org.apache.jsp.message_jsp:398)
    	at org.apache.jsp.message_jsp._jspx_meth_c_otherwise_0(org.apache.jsp.message_jsp:332)
    	at org.apache.jsp.message_jsp._jspx_meth_c_choose_0(org.apache.jsp.message_jsp:150)
    	at org.apache.jsp.message_jsp._jspService(org.apache.jsp.message_jsp:92)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
    	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:63)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    	at org.apache.activemq.web.SessionFilter.doFilter(SessionFilter.java:46)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    	at org.apache.activemq.web.filter.ApplicationContextFilter.doFilter(ApplicationContextFilter.java:81)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    	at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
    	at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
    Caused by: javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.IOException: org.springframework.integration.message.GenericMessage
    	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
    	at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:183)
    	at org.apache.activemq.web.MessageQuery.getBody(MessageQuery.java:78)
    	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 javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
    	... 41 more
    Caused by: java.io.IOException: org.springframework.integration.message.GenericMessage
    	at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:179)
    	... 47 more
    Last edited by ashleyvijay; Nov 5th, 2008, 08:48 AM.

  • #2
    Try it without setting the message-converter

    by default the JMS gateway does the below. One converter for the header the other to convert the payload.

    Code:
    private volatile MessageConverter messageConverter = new HeaderMappingMessageConverter(new SimpleMessageConverter());
    Last edited by JonasPartner; Nov 5th, 2008, 09:12 AM. Reason: typo

    Comment


    • #3
      Thanks for the reply.I removed the messageconverter setting but still the same error but I can c the messages reaching the queue and not the message payload

      Comment


      • #4
        Is this all in one VM? Looking at the ActiveMQ code I would say/guess that you are reading this message, which contains the GenericMessage as a payload in a vm without the SI GenericMessage class on the classpath since it is failing to create the GenericMessage from the serialized representation in the payload of the JMS message.

        Comment


        • #5
          Ok I think my flow is not right.Well i tried to invoke a Spring WS in the same way as WebServiceDemo(latest vesrion) using webserviceOutboundGateway which will log the response from the webservice into the console which worked perfectly fine.Now I wanted the same response from the webservice to be logged into the console as well send it as jms message to the ActiveMQQueue at once so I made the sendChannel as publish-subscribe-channel.But Im wondering by using jms outbound gateway how can it read the response without giving any uri unlike in webservice outbound gateway.Before the latest realse I used <ws-handler> which ws easy to send the response to different target adapters.
          Last edited by ashleyvijay; Nov 5th, 2008, 10:30 AM.

          Comment


          • #6
            Sorry I am little confused about what you are trying to achieve. I would suggest that you would benefit from looking into either Spring Source support or consultancy services Spring Source.

            Comment


            • #7
              Thanks for the help.Finally I have just one question.Can v use <ws-handler> with the latest realease version.If yes what would be the namespace support??

              Comment


              • #8
                Please consult the reference documentation:
                http://static.springframework.org/sp...erence.html#ws

                The 'ws-handler' has been replaced with the 'outbound-gateway' element within the "ws" namespace as described there.

                Comment


                • #9
                  Oh ok.Sorry for the confusion Jonas.It ws my mistake.Currently I have this in my config where the response from the webservice is logged into Console as well as sent as JMS Message to the queue.The problem is I can c the messages delivered into the queue but I cant c the message payload.Im getting the same error message as mentioned in the beginning of this thread.Kindly help as I have to refractor my code according to latest release version interms of finding a replacement for <ws-handler> which I had it in my code previously
                  Code:
                  <message-bus/>
                     <publish-subscribe-channel id="sendChannel"/>
                   <ws:outbound-gateway id="WebServiceConsoleGateway"
                  				         request-channel="sendChannel" 
                  				         reply-channel="WebServiceConsoleReceiveChannel"
                  				         uri="http://localhost:8080/Trial1/companyservice"/>
                  <ws:outbound-gateway id="WebServiceJMSGateway"
                  				         request-channel="sendChannel" 
                  				         reply-channel="WebServiceJMSReceiveChannel"
                  				         uri="http://localhost:8080/Trial1/companyservice"/>
                  	
                  <jms:outbound-gateway id="jmsGateway"
                                        jms-queue="DemoQueue"
                                        request-channel="WebServiceJMSReceiveChannel"
                                       connection-factory="connectionFactory"/>
                      
                  <beans:bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
                  <beans:property name="brokerURL" value="tcp://localhost:61616" />
                  </beans:bean>
                  	
                  <beans:bean id="DemoQueue" class="org.apache.activemq.command.ActiveMQQueue">
                  <beans:constructor-arg value="queue.demo" index="0"/>
                  </beans:bean>
                   
                  <stream:stdout-channel-adapter id="WebServiceConsoleReceiveChannel"/>
                  
                  </beans:beans>
                  Last edited by ashleyvijay; Nov 5th, 2008, 11:19 AM.

                  Comment


                  • #10
                    That configuration you had previously looks wrong actually. I doubt if you really intend to invoke the web-service twice which is exactly what would happen with that publish-subscribe-channel *preceding* the WS invocation.

                    I believe what you want is something like the following:
                    Code:
                    <ws:outbound-gateway id="WebServiceGateway" request-channel="sendChannel" 
                    reply-channel="WebServiceReceiveChannel"
                    				    uri="http://localhost:8080/Trial1/companyservice"/>
                    
                    <publish-subscribe-channel id="WebServiceReceiveChannel"/>
                    
                    <stream:stdout-channel-adapter channel="WebServiceReceiveChannel"/>
                    
                    <jms:outbound-channel-adapter channel="WebServiceReceiveChannel" ... />
                    As Jonas mentioned above, based on the level of assistance you seem to be looking for, you should really consider SpringSource support. I would also recommend carefully reading the entire Reference Documentation.

                    Comment


                    • #11
                      Ah yes this is what Im looking for.Previously I had <ws-handler> in my code which made it much easier.Now i will try ur code.Thank u.

                      Comment


                      • #12
                        Hey Mark, I tried ur code but Im getting the same JMSException as mentioned in the beginning of this post which is: I can c the message being deleivered to the queue but when I open to c the message it gives me this JMS exception.Please help.Im really getting frustrated at this exception(please c for the exception at beginning of this post)
                        Code:
                        <channel id="sendChannel"/>
                          <ws:outbound-gateway id="WebServiceGateway"
                        				         request-channel="sendChannel" 
                        				         reply-channel="WebServiceReceiveChannel"
                        				         uri="http://localhost:8080/Trial1/companyservice"/>
                        <publish-subscribe-channel id="WebServiceReceiveChannel"/>
                        	
                        <jms:outbound-gateway  id="jmsGateway" request-channel="WebServiceReceiveChannel" connection-factory="connectionFactory" jms-queue="HelloQueue"/>
                            
                        <beans:bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
                          <beans:property name="brokerURL" value="tcp://localhost:61616" />
                        </beans:bean>
                        	
                        <beans:bean id="HelloQueue" class="org.apache.activemq.command.ActiveMQQueue">
                        <beans:constructor-arg value="HelloQueueWorlds" index="0"/>
                        </beans:bean>
                        Last edited by ashleyvijay; Nov 5th, 2008, 12:26 PM.

                        Comment


                        • #13
                          Did you read Jonas reply above regarding that JMSException? It looks like a serialization issue and it's at the JMS level. I don't think it's related to Spring Integration - probably you need to make sure you have the right classes on both sides of the JMS communication.

                          Comment


                          • #14
                            Originally posted by JonasPartner View Post
                            Looking at the ActiveMQ code I would say/guess that you are reading this message, which contains the GenericMessage as a payload in a vm without the SI GenericMessage class on the classpath since it is failing to create the GenericMessage from the serialized representation in the payload of the JMS message.
                            Well I have the SI GenericMessage class: org.springframework.integration.message.GenericMes sage on the classpath but still what is the problem?? Please help.Im really going crazy with this Exception. If its still a serialization/deserialization please tell me how to solve it please...

                            Comment


                            • #15
                              Given the other problem that you were having (http://forum.springframework.org/showthread.php?t=63106), I would highly recommend verifying that you have only one version on the classpath and that it is the same version on both sides of the JMS communication.

                              This problem looks like something in your configuration/setup and is very likely not a Spring Integration issue. Based on the stack trace, everything is as-expected until the serialization. So, there's not really any assistance we can provide. You need to verify your setup.

                              Comment

                              Working...
                              X