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

    MDB attempting to raise an event - No Application Context active


      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


        • 1. Re: MDB attempting to raise an event - No Application Context active

          Looks similar to JBSEAM-2286

          • 2. Re: MDB attempting to raise an event - No Application Context active

            Thanks, but I looked at the other postings, I did not see anything that solved the problem.


            I was able to get past the No Application Context active by:


            adding the following to components.xml


            
               <component class="org.jboss.seam.remoting.messaging.SubscriptionRegistry" installed="true">
            
                    <property name="allowedTopics">myTopic</property>
            
                </component>
            
            



            2) adding @name to the MDB


            Now the code should be raising an event that is caught by another component.


            There are no exceptions thrown.

            • 3. Re: MDB attempting to raise an event - No Application Context active

              I downloaded and tried my application with the latest 2.0.2.GA; I do not see a difference, I was using 2.1.0.A1
              I am using jboss-4.2.2.GA


              I believe there is something incorrect with the state of my MDB. It acts like I instantiated another version of my seam app. Within my MDB I generate an event that is caught within an application scoped bean; that bean send another event to a page scoped bean. It works differently depended on where I initiate
              the event from.


              From Web page - click a link - generate the event handled by application scoped bean


              From MDB - onMessage - generate the event handled by the application scoped bean


              In either case the application scoped bean genrates another event that is caught by a page scoped bean.


              In first case I see the event caught by page scoped bean.
              In second case I do not, it is caught by the application scoped but not the page scoped.


              The MDB bean, application and page scoped beans are in the same jar. I have a polling service that generates the JMS message, that is in a sar. These two files and the .war are in the .ear


              What I am trying to do is get the data that is polled delivered to one or more users viewing that device.


              Any help would be appreciated. Thanks.

              • 4. Re: MDB attempting to raise an event - No Application Context active
                pmuir

                The PAGE scope isn't active during calls originated via an MDB.

                • 5. Re: MDB attempting to raise an event - No Application Context active

                  I am trying to get an alert shown to all logged in users, is there a way that I can do this?


                  The alert is generated by the server and is not reaction to something the user did.


                  Thanks