2 Replies Latest reply on Nov 23, 2011 6:29 AM by dev0

    JMSException when using XMLGregorianCalendar

    dev0 Newbie

      I am experiencing problems when sending a date across my HornetQ on JBoss 7.0.2.Final.

       

      I have reduced the problem to the following simple example where a date is send in through a webservice and send across the queue. The date is printed to sys out on both sides. Both sides are deployed in the same module and it looks like the same class loader is being used.

       

      The Web-service:

       

      @Stateless
      @Local(SimpleTestService.class)
      @WebService(name = "ServiceManagementConsumerPort", targetNamespace = "http://com.company/services", serviceName = "ServiceManagementConsumerService")
      @WebContext(contextRoot="/webservices", urlPattern="/SimpleTestService")
      public class SimpleTestService {
      
                @Resource(mappedName = "java:/queue/date_operations")
                private Queue dateQueue;
        
                @Resource(mappedName = "java:/ConnectionFactory")
                private QueueConnectionFactory qcf;
        
                public void printDate(XMLGregorianCalendar date) {
                          try {
                                    System.out.println("Date is ..." + date.toString());
                                    QueueConnection conn = qcf.createQueueConnection();
                                    QueueSession session = conn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
                                    conn.start();
      
      
                                    QueueSender send = session.createSender(dateQueue);
                                    ObjectMessage tm = session.createObjectMessage((Serializable) date);
                                    send.send(tm);
                                    send.close();
      
      
                                    conn.stop();
                                    session.close();
                                    conn.close();
                          } catch (Exception e) {
                                    throw new RuntimeException(e);
                          } 
                }
      }
      

       

      On the receiving side we have the following message bean:

       

      @MessageDriven(name = "DatePrinterMessageBean", activationConfig = { 
                          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                          @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/date_operations"),
                          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") 
                })
      public class DatePrinterMessageBean implements MessageListener {
      
      
                @Override
                public void onMessage(Message queued) {
        
                          XMLGregorianCalendar date = null;
                          try {
                                    ObjectMessage message = (ObjectMessage)queued;
                                    date = (XMLGregorianCalendar) message.getObject();
                                    System.out.println("Date - from the other side - is ..." + date.toString());
      
      
        
                          } catch (Exception e) {
                                    throw new RuntimeException(e);
                          }
                }
      }
      

       

      When XMLGregorianCalendar is substituted with String the following is printed (with arg "HEY"):

      13:36:09,722 INFO  [stdout] (http--127.0.0.1-8080-1) Date is ...HEY
      13:36:09,755 INFO  [stdout] (Thread-4 (group:HornetQ-client-global-threads-33481396)) Date - from the other side - is ...HEY
      

       

      This shows that the Queue setup is working as expected!

       

      When called with the XMLGregorianCalendar it results in the following Stacktrace:

       

      13:39:25,837 ERROR [org.hornetq.ra.inflow.HornetQMessageHandler] (Thread-4 (group:HornetQ-client-global-threads-24564705)) Failed to deliver message: java.lang.RuntimeException: javax.jms.JMSException: org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl from [Module "org.hornetq:main" from local module loader @18a8ce2 (roots: D:\development\bundles\jboss-as-7.0.2.Final\jboss-as-7.0.2.Final\modules)]
                at com.company.messagebeans.DatePrinterMessageBean.onMessage(DatePrinterMessageBean.java:28)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_17]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_17]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_17]
                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_17]
                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:50)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.as.ejb3.component.messagedriven.MessageDrivenInvocationContextInterceptor.processInvocation(MessageDrivenInvocationContextInterceptor.java:60)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
                at javax.jms.MessageListener$$$view15.onMessage(Unknown Source)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_17]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_17]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_17]
                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_17]
                at org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140)
                at org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73)
                at $Proxy89.onMessage(Unknown Source)          at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278)
                at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:866)
                at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:44)
                at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:983)
                at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_17]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_17]
                at java.lang.Thread.run(Thread.java:619) [:1.6.0_17]
      Caused by: javax.jms.JMSException: org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl from [Module "org.hornetq:main" from local module loader @18a8ce2 (roots: D:\development\bundles\jboss-as-7.0.2.Final\jboss-as-7.0.2.Final\modules)]
                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
                at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316) [:1.6.0_17]
                at java.lang.Class.forName0(Native Method) [:1.6.0_17]
                at java.lang.Class.forName(Class.java:247) [:1.6.0_17]
                at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604) [:1.6.0_17]
                at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)
                at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575) [:1.6.0_17]
                at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) [:1.6.0_17]
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) [:1.6.0_17]
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) [:1.6.0_17]
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) [:1.6.0_17]
                at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)
                at com.company.messagebeans.DatePrinterMessageBean.onMessage(DatePrinterMessageBean.java:23)
                ... 42 more
      

       

      Debugging shows that org.hornetq.utils.ObjectInputStreamWithClassLoader uses:

      Thread.currentThread().getContextClassLoader();
      

       

      and when inspecting this classloader on both sides of the queue it seems to be the same - however on one side the XMLGregorianCalendar can be resolved where as on the other it looks like it is failing in resolving the class.

       

      Any suggestions would be greatly appreciated.

       

      Kind Regards

       

      Lasse

        • 1. Re: JMSException when using XMLGregorianCalendar
          Clebert Suconic Master

          This is more an AS7 question than HornetQ. The EJB MDB layer should setup the classLoader.

           

          I believe there is an issue opened within AS7. Maybe you could/should post on AS7 forum pointing to this thread

          • 2. Re: JMSException when using XMLGregorianCalendar
            dev0 Newbie

            Looks like my problem is more or less comparable to the one solved by Daniel Bevenius in this thread:

            http://community.jboss.org/thread/174528

             

            So what I did was add a dependecy to org.apache.xerces.

             

            Solving this in maven:

             

            <build>
                      <plugins>
                                <plugin>
                                          <groupId>org.apache.maven.plugins</groupId>
                                          <artifactId>maven-jar-plugin</artifactId>
                                          <configuration>
                                                    <archive>
                                                              <manifestEntries>
                                                                        <Dependencies>org.apache.xerces</Dependencies>
                                                              </manifestEntries>
                                                    </archive>
                                          </configuration>
                                </plugin>
                      </plugins>
            </build>