0 Replies Latest reply on Nov 2, 2006 9:19 AM by Stephan Pelikan

    env-entry not in

    Stephan Pelikan Newbie

      Hello,

      I cannot get an env-entry via naming. Resource-injection works but I need it via naming, because it is al list of env-entries which can vary in different deployments:

      <ejb-jar>
       <enterprise-beans>
       <session>
       <ejb-name>SessionService</ejb-name>
       <ejb-class>service.SessionServiceImpl</ejb-class>
       <env-entry>
       <env-entry-name>deUrlPrefix</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>http://localhost:7500/axis/</env-entry-value>
       </env-entry>
       </session>
       </enterprise-beans>
      </ejb-jar>
      
      package service;
      
      @Stateful(name="SessionService")
      @RemoteBinding(jndiBinding="ejb/SessionService")
      public class SessionServiceImpl implements SessionService {
       public void businessMethod() throws NamingException {
       Context ctx = null;
       try {
       ctx = new InitialContext();
       String prefix = (String) ctx.lookup("java:comp/env/enUrlPrefix"); // throws
       } finally {
       if (ctx != null) {
       try {
       ctx.close();
       } catch (Throwable e) {
       SessionServiceImpl.logger.error(
       "could not close context", e);
       }
       }
       }
       }
      }


      Calling this business method throws this exception:

      javax.naming.NameNotFoundException: env not bound

      If I add

      <injection-target>
       <injection-target-class>
       at.apa.defacto.service.SessionServiceImpl
       </injection-target-class>
       <injection-target-name>prefix</injection-target-name>
       </injection-target>

      and

      @Resource
       private String prefix;


      the env-entry is injected but also not available via naming.

      Is this a bug? Is anything wrong? Does anybody has similar expirences?

      thanks,
      Stephan