activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack <jackgray1...@gmail.com>
Subject Re: About ActiveMQ
Date Tue, 13 Nov 2007 10:33:35 GMT
*I have use a ActiveMQObjectMessage,please look at the code below:*


public class OrderMessageConverter implements MessageConverter {

 /*
  * (non-Javadoc)
  *
  * @see
org.springframework.jms.support.converter.MessageConverter#toMessage(
java.lang.Object,
  *      javax.jms.Session)
  */
 public Message toMessage(Object obj, Session session) throws JMSException {
  //check Type
  if (obj instanceof Order) {
   ActiveMQObjectMessage objMsg = (ActiveMQObjectMessage)
session.createObjectMessage();
   Map<String, Order> map = new HashMap<String, Order>();
   map.put("Order", (Order) obj);
   objMsg.setObjectProperty("Map", map);
   return objMsg;
  } else {
   throw new JMSException("Object:[" + obj + "] is not Order");
  }

 }

 /*
  * (non-Javadoc)
  *
  * @see
org.springframework.jms.support.converter.MessageConverter#fromMessage(
javax.jms.Message)
  */
 public Object fromMessage(Message msg) throws JMSException {
  if (msg instanceof ObjectMessage) {
   return ((Map) ((ObjectMessage)
msg).getObjectProperty("Map")).get("Order");
  } else {
   throw new JMSException("Msg:[" + msg + "] is not Map");
  }
 }

}


2007/11/13, James Strachan <james.strachan@gmail.com>:
>
> looks like you are putting a non primitive type in a property or
> MapMessage which is not allowed in JMS. Try use an ObjectMessage
>
> On 13/11/2007, jack <jackgray1983@gmail.com> wrote:
> > *That's all:*
> >
> > java.io.IOException: Object is not a primitive:
> > org.springside.bookstore.model.Order@1e5d007
> >  at org.apache.activemq.util.MarshallingSupport.marshalPrimitive(
> > MarshallingSupport.java:132)
> >  at org.apache.activemq.util.MarshallingSupport.marshalPrimitiveMap(
> > MarshallingSupport.java:31)
> >  at org.apache.activemq.util.MarshallingSupport.marshalPrimitive(
> > MarshallingSupport.java:124)
> >  at org.apache.activemq.util.MarshallingSupport.marshalPrimitiveMap(
> > MarshallingSupport.java:31)
> >  at org.apache.activemq.command.Message.beforeMarshall(Message.java:190)
> >  at org.apache.activemq.openwire.v2.MessageMarshaller.looseMarshal(
> > MessageMarshaller.java:243)
> >  at
> org.apache.activemq.openwire.v2.ActiveMQMessageMarshaller.looseMarshal(
> > ActiveMQMessageMarshaller.java:111)
> >  at
> >
> org.apache.activemq.openwire.v2.ActiveMQObjectMessageMarshaller.looseMarshal
> > (ActiveMQObjectMessageMarshaller.java:111)
> >  at org.apache.activemq.openwire.OpenWireFormat.marshal(
> OpenWireFormat.java
> > :167)
> >  at org.apache.activemq.store.jdbc.JDBCMessageStore.addMessage(
> > JDBCMessageStore.java:59)
> >  at org.apache.activemq.store.memory.MemoryTransactionStore.addMessage(
> > MemoryTransactionStore.java:224)
> >  at org.apache.activemq.store.memory.MemoryTransactionStore$1.addMessage
> (
> > MemoryTransactionStore.java:117)
> >  at org.apache.activemq.broker.region.Queue.sendMessage(Queue.java:333)
> >  at org.apache.activemq.broker.region.Queue.send(Queue.java:326)
> >  at org.apache.activemq.broker.region.AbstractRegion.send(
> > AbstractRegion.java:292)
> >  at org.apache.activemq.broker.region.RegionBroker.send(
> RegionBroker.java
> > :382)
> >  at org.apache.activemq.broker.TransactionBroker.send(
> TransactionBroker.java
> > :193)
> >  at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:126)
> >  at org.apache.activemq.broker.CompositeDestinationBroker.send(
> > CompositeDestinationBroker.java:98)
> >  at org.apache.activemq.broker.MutableBrokerFilter.send(
> > MutableBrokerFilter.java:136)
> >  at org.apache.activemq.broker.TransportConnection.processMessage(
> > TransportConnection.java:498)
> >  at org.apache.activemq.command.ActiveMQMessage.visit(
> ActiveMQMessage.java
> > :604)
> >  at org.apache.activemq.broker.TransportConnection.service(
> > TransportConnection.java:294)
> >  at org.apache.activemq.broker.TransportConnection$1.onCommand(
> > TransportConnection.java:185)
> >  at org.apache.activemq.transport.ResponseCorrelator.onCommand(
> > ResponseCorrelator.java:95)
> >  at org.apache.activemq.transport.TransportFilter.onCommand(
> > TransportFilter.java:65)
> >  at org.apache.activemq.transport.vm.VMTransport.syncOneWay(
> VMTransport.java
> > :96)
> >  at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java
> :83)
> >  at org.apache.activemq.transport.MutexTransport.oneway(
> MutexTransport.java
> > :47)
> >  at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(
> > ResponseCorrelator.java:69)
> >  at org.apache.activemq.transport.ResponseCorrelator.request(
> > ResponseCorrelator.java:74)
> >  at org.apache.activemq.ActiveMQConnection.syncSendPacket(
> > ActiveMQConnection.java:1175)
> >  at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1551)
> >  at org.apache.activemq.ActiveMQMessageProducer.send(
> > ActiveMQMessageProducer.java:465)
> >  at org.apache.activemq.ActiveMQMessageProducer.send(
> > ActiveMQMessageProducer.java:356)
> >  at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java
> :537)
> >  at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java
> :513)
> >  at org.springframework.jms.core.JmsTemplate$2.doInJms(JmsTemplate.java
> :479)
> >  at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java
> :430)
> >  at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:477)
> >  at org.springframework.jms.core.JmsTemplate.convertAndSend(
> JmsTemplate.java
> > :558)
> >  at
> org.springside.bookstore.components.activemq.OrderMessageProducer.send(
> > OrderMessageProducer.java:27)
> >  at org.springside.bookstore.service.order.OrderManager.notifyOrder(
> > OrderManager.java:96)
> >  at org.springside.bookstore.service.order.OrderManager.placeOrder(
> > OrderManager.java:62)
> >  at
> >
> org.springside.bookstore.service.order.OrderManager$$FastClassByCGLIB$$e36986ee.invoke
> > (<generated>)
> >  at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
> >  at
> >
> org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint
> > (Cglib2AopProxy.java:714)
> >  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> (
> > ReflectiveMethodInvocation.java:162)
> >  at
> >
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
> > TransactionInterceptor.java:107)
> >  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> (
> > ReflectiveMethodInvocation.java:185)
> >  at
> >
> org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept
> > (Cglib2AopProxy.java:652)
> >  at
> >
> org.springside.bookstore.service.order.OrderManager$$EnhancerByCGLIB$$97104372.placeOrder
> > (<generated>)
> >  at org.springside.bookstore.web.shop.OrderAction.newOrder(
> OrderAction.java
> > :83)
> >  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:597)
> >  at org.apache.struts.actions.DispatchAction.dispatchMethod(
> > DispatchAction.java:270)
> >  at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java
> > :187)
> >  at org.apache.struts.action.RequestProcessor.processActionPerform(
> > RequestProcessor.java:431)
> >  at org.apache.struts.action.RequestProcessor.process(
> RequestProcessor.java
> > :236)
> >  at org.apache.struts.action.ActionServlet.process(ActionServlet.java
> :1196)
> >  at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java
> :432)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:269)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(
> > AbstractExportFilter.java:49)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at
> >
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal
> > (OpenSessionInViewFilter.java:174)
> >  at org.springframework.web.filter.OncePerRequestFilter.doFilter(
> > OncePerRequestFilter.java:77)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(
> > CharacterEncodingFilter.java:78)
> >  at org.springframework.web.filter.OncePerRequestFilter.doFilter(
> > OncePerRequestFilter.java:77)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:264)
> >  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(
> > FilterSecurityInterceptor.java:107)
> >  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(
> > FilterSecurityInterceptor.java:72)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(
> > ExceptionTranslationFilter.java:110)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at
> org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter
> > (AnonymousProcessingFilter.java:125)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(
> > RememberMeProcessingFilter.java:142)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at
> >
> org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter
> (
> > SecurityContextHolderAwareRequestFilter.java:81)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(
> > AbstractProcessingFilter.java:217)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java
> :106)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at
> org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
> > HttpSessionContextIntegrationFilter.java:229)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.util.FilterChainProxy.doFilter(
> FilterChainProxy.java
> > :148)
> >  at org.acegisecurity.util.FilterToBeanProxy.doFilter(
> FilterToBeanProxy.java
> > :98)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at org.apache.catalina.core.StandardWrapperValve.invoke(
> > StandardWrapperValve.java:213)
> >  at org.apache.catalina.core.StandardContextValve.invoke(
> > StandardContextValve.java:174)
> >  at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java
> > :127)
> >  at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java
> > :117)
> >  at org.apache.catalina.core.StandardEngineValve.invoke(
> > StandardEngineValve.java:108)
> >  at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java
> > :151)
> >  at org.apache.coyote.http11.Http11Processor.process(
> Http11Processor.java
> > :874)
> >  at
> >
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> > (Http11BaseProtocol.java:665)
> >  at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> > PoolTcpEndpoint.java:528)
> >  at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
> > LeaderFollowerWorkerThread.java:81)
> >  at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
> > ThreadPool.java:689)
> >  at java.lang.Thread.run(Thread.java:619)
> > 2007-11-13 17:27:14,937 ERROR [/BookStore2/shop/order.do] -
> <Uncategorized
> > exception occured during JMS processing; nested exception is
> > javax.jms.JMSException: Failed to broker message:
> > ID:123456-8f2a9a43-1955-1194945972046-3:1:1:1:1 in container:
> > java.io.IOException: Object is not a primitive:
> > org.springside.bookstore.model.Order@1e5d007>
> > javax.servlet.ServletException: Uncategorized exception occured during
> JMS
> > processing; nested exception is javax.jms.JMSException: Failed to broker
> > message: ID:123456-8f2a9a43-1955-1194945972046-3:1:1:1:1 in container:
> > java.io.IOException: Object is not a primitive:
> > org.springside.bookstore.model.Order@1e5d007
> >  at org.apache.struts.action.RequestProcessor.processException(
> > RequestProcessor.java:535)
> >  at org.apache.struts.action.RequestProcessor.processActionPerform(
> > RequestProcessor.java:433)
> >  at org.apache.struts.action.RequestProcessor.process(
> RequestProcessor.java
> > :236)
> >  at org.apache.struts.action.ActionServlet.process(ActionServlet.java
> :1196)
> >  at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java
> :432)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:269)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(
> > AbstractExportFilter.java:49)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at
> >
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal
> > (OpenSessionInViewFilter.java:174)
> >  at org.springframework.web.filter.OncePerRequestFilter.doFilter(
> > OncePerRequestFilter.java:77)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(
> > CharacterEncodingFilter.java:78)
> >  at org.springframework.web.filter.OncePerRequestFilter.doFilter(
> > OncePerRequestFilter.java:77)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:264)
> >  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(
> > FilterSecurityInterceptor.java:107)
> >  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(
> > FilterSecurityInterceptor.java:72)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(
> > ExceptionTranslationFilter.java:110)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at
> org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter
> > (AnonymousProcessingFilter.java:125)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(
> > RememberMeProcessingFilter.java:142)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at
> >
> org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter
> (
> > SecurityContextHolderAwareRequestFilter.java:81)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(
> > AbstractProcessingFilter.java:217)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java
> :106)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at
> org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
> > HttpSessionContextIntegrationFilter.java:229)
> >  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
> > FilterChainProxy.java:274)
> >  at org.acegisecurity.util.FilterChainProxy.doFilter(
> FilterChainProxy.java
> > :148)
> >  at org.acegisecurity.util.FilterToBeanProxy.doFilter(
> FilterToBeanProxy.java
> > :98)
> >  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> >  at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >  at org.apache.catalina.core.StandardWrapperValve.invoke(
> > StandardWrapperValve.java:213)
> >  at org.apache.catalina.core.StandardContextValve.invoke(
> > StandardContextValve.java:174)
> >  at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java
> > :127)
> >  at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java
> > :117)
> >  at org.apache.catalina.core.StandardEngineValve.invoke(
> > StandardEngineValve.java:108)
> >  at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java
> > :151)
> >  at org.apache.coyote.http11.Http11Processor.process(
> Http11Processor.java
> > :874)
> >  at
> >
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> > (Http11BaseProtocol.java:665)
> >  at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> > PoolTcpEndpoint.java:528)
> >  at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
> > LeaderFollowerWorkerThread.java:81)
> >  at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
> > ThreadPool.java:689)
> >  at java.lang.Thread.run(Thread.java:619)
> >
> >
> >
> >
> > 2007/11/13, James Strachan <james.strachan@gmail.com>:
> > >
> > > could you provide a full stack trace please?
> > >
> > > On 13/11/2007, jack <jackgray1983@gmail.com> wrote:
> > > > Hi:
> > > >
> > > > I'm a Chinese user, I'm very glad to write to you. Now I have a
> question
> > > > about the activemq, when I want to store the message to
> > > > database, always have a exception:java.io.IOException: Object is not
> a
> > > > primitive: org.springside.bookstore.model.Order@1fe9830
> > > > .So please help to tell me the reason of the problem.Thank you very
> > > much!
> > > >
> > > >
> > > > --
> > > > JackGray
> > > >
> > >
> > >
> > > --
> > > James
> > > -------
> > > http://macstrac.blogspot.com/
> > >
> > > Open Source SOA
> > > http://open.iona.com
> > >
> >
> >
> >
> > --
> > JackGray
> >
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>



-- 
JackGray

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message