5 Replies Latest reply on May 29, 2008 5:11 PM by akearns

    MDB attempting to raise an event - No Application Context active

    akearns Newbie

      The existing application sends JMS message to deliver both information and status.


      I have my application deployed with an MDB that catches these messages. I am trying to call Events.raiseEvent(key, event) thinking that this should work. It does not, I get an illegalStateException "no application context active"
      My question: how can I get a context that I can use?


      code follows:


      
      @AutoCreate
      
      @MessageDriven(activationConfig = {
      
        @ActivationConfigProperty(propertyName="destinationType",
      
          propertyValue="javax.jms.Topic"),
      
        @ActivationConfigProperty(propertyName="destination",
      
          propertyValue=TopicPublisher.CLIENT_TOPIC)
      
      })
      
      public class ProAsyncMDB implements MessageListener
      
      {
      
        @In(create = true)
      
        Context applicationContext;
      
           
      
        public void onMessage (Message message)
      
        {
      
          String func = "ProAsyncMDB.onMessage()...";
      
          System.err.println(func + "starting");
      
                           
      
          Object o = ((ObjectMessage )message).getObject();
      
          ProJmsVisualObject jmsVisual = (ProJmsVisualObject )o;
      
          Events.instance().raiseEvent("processVisual",jmsVisual);
      
        }
      
      }
      
      



      I have tried using


      
      @Stateless
      
      @Name("asyncMDB")
      
      @Scope(ScopeType.Application)
      
      
      



      In the current state of the code the applicationContext is null. The exception is raised when I attempt to sent the event.


      My observer for the Event just logs a message if it sees one. That code is page scoped, where my mdb can be application scoped.


      Another restriction I have is no java script, I tried the chatroom example that works within my envionment.


      Thanks