Your code shows that the datasource is being assigned to a local variable in the constructor. It needs to be stored in an instance variable because the EJB container won't necessarily create a new instance of the session bean whenever ejbCreate is called (it can pool instances and reuse them). Also I would recommend doing the lookup in the  setSessionContext method. I think the spec requires the container to make JNDI lookups and other server services available  in setSessionContext method, not sure if it requires those services to be available in the constructor.




Reply via email to