[jboss-user] [EJB 3.0 Development] New message: "Lookup to java:comp/EJBContext during postconstruction"

Marius Bogoevici do-not-reply at jboss.com
Wed Mar 10 00:35:09 EST 2010


User development,

A new message was posted in the thread "Lookup to java:comp/EJBContext during postconstruction":

http://community.jboss.org/message/530930#530930

Author  : Marius Bogoevici
Profile : http://community.jboss.org/people/marius.bogoevici

Message:
--------------------------------------------------------------
I will just refer to the problem indicated in http://seamframework.org/Community/TheMessageDrivenBeanSagaContinues
 
While a CDI problem per se, it seems like doing this:
 
@MessageDriven(activationConfig={
      @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
      @ActivationConfigProperty(propertyName="destination",     propertyValue="queue/testQueue")
  })
public class MilkMan implements MessageListener
{
 
   @PostConstruct
   public void doAfterConstruction()
   {
      try
      {
         Context context = ((Context) new InitialContext().lookup("java:comp/EJBContext"));
      }
      catch (NamingException e)
      {
         e.printStackTrace();
      }
   }
 
   @Inject Control control;
 
   public void onMessage(Message message)
   {
      try
      {
         control.setMessageDelivered(((TextMessage) message).getText().equals(EJBTest.MESSAGE));
      }
      catch (JMSException e)
      {
         throw new RuntimeException(e);
      }
   }
 
}
 
 
will cause the deployment to fail, since doing that lookup from within the postconstructor does not get all the expected interceptors applied. Of course, this is not how exactly we intent to use this from Weld, but doing injection of resources during postconstruction has a similar effect.
 
Now, I would really like to know whether this assessment is corect and if that is something that is essentially expected to happen given the circumstances. If this is expected behaviour, then I think that we could work around this by treating EJBContext distinctly when injecting resources, but if not, then what would you think that would be the appropriate solution for doing a correct lookup for the purposes of CDI/Weld integration?

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/530930#530930




More information about the jboss-user mailing list