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.
About Question enthuware.oce-ejbd.v6.2.555 :
Moderator: admin
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.555 :
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.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.555 :
Hi, admin.
Thanks for your previous reply.
In explanation 1,
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.
Thanks for your previous reply.
In explanation 1,
But I can do this:Bean environment is not set in the constructor. Therefore, the bean will not be able to get the connection parameters in the constructor.
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 ) {....}
}
}
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.555 :
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.
Who is online
Users browsing this forum: No registered users and 83 guests