tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen, Robert R" <>
Subject TomEE+ActiveMQ 1.5.2: container classloader used for message deserialization conflicts with LazyStopWebappClassLoader
Date Mon, 28 Oct 2013 15:54:42 GMT
Although it appears this topic has been discussed in other threads, I don't see guidance on
the fix.

My tomee.xml contains the following boilerplate:
  <!-- see -->

  <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
    BrokerXmlConfig =  broker:(tcp://localhost:61616)
    ServerUrl       =  tcp://localhost:61616

  <Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
    ResourceAdapter = MyJmsResourceAdapter

  <Container id="MyJmsMdbContainer" ctype="MESSAGE">
    ResourceAdapter = MyJmsResourceAdapter


My webapp is initialized with container resources as follows. This results in a ConnectionFactory
with the standard class loader, not the webapp loader, although the thread running the init()
call has the webapp 

public class InitServlet extends HttpServlet {

   private ConnectionFactory connectionFactory;

   public void init(ServletConfig config) throws ServletException

         // ------- JMS service start --------------
         try {
            connection = connectionFactory.createConnection();

            // set up cfgMgmt services
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MySvc mySvc = new MySvc (session);

public class MySvc implements MessageListener
   private Session session;
   private MessageConsumer consumer;
   private MessageProducer writer;

   public MySvc(Session session)
      this.session = session;
         writer = session.createProducer(null); 
         Destination destination_in =
         consumer = session.createConsumer(destination_in);


Because MySvc was created by the LazyStopWebappClassLoader thread, it's objects are loaded
by it. 
However when I receive a message:

   public void onMessage(Message request)
            Object reqObj = ((ObjectMessage) request).getObject();
            if (!(reqObj instanceof BaseMsg)) {
               throw new Exception("FUNCTIONALITY_NOT_SUPPORTED");

the deserialization was done by the connectionFactory's classLoader (not the webapp loader),
so the class instanceof compare fails.

Is there a common sense way to resolve this in the TomEE environment configuration?

   "The most precious thing we have is life, yet it has absolutely no
    trade-in value."

Robert R. Allen                     Sr Principal Software Architect  (919)677-2899  CA Technologies

View raw message