About Question enthuware.oce-ejbd.v6.2.555 :

Moderator: admin

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

About Question enthuware.oce-ejbd.v6.2.555 :

Post by himaiMinh »

What happens if loading the data involves the using of resource managers, such as QueueConnectionFactory?
In stateless bean, accessing the resource managers are not allowed in @PostConstruct method.

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.555 :

Post by admin »

The question explicitly says web service. But as you said you can't use resource managers in @PostContruct.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.555 :

Post by himaiMinh »

Hi, admin.
Thanks for your previous reply.
In explanation 1,
Bean environment is not set in the constructor. Therefore, the bean will not be able to get the connection parameters in the constructor.
But I can do this:
Suppose the LoadDataBean is packaged in a .war file with some other beans. The bean environment is shared among other beans in the .war file.

Code: Select all

@Stateless
public class  LoadDataBean{
 private String connectionDetail;

 public LoadDataBean(){
       try{
        InitalContext context = new InitialContext();
         //Suppose there is an environment variable connectionDetail set by other beans in the same .war
        String detail=  context.lookup("java:comp/env/connectionDetail");
        connectionDetail = loadData(detail); //where loadData connects to a web service which gets the configuration in the bean's environment.
          }
          catch (NamingException e ) {....}
 
   }


}

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.555 :

Post by admin »

The container may prohibit the bean from using InitialContext itself in the constructor. So what you are saying may or may not work. Regardless, it is not as per the specification.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests