[jboss-user] [EJB 3.0] - env-entry not in

a9702466 do-not-reply at jboss.com
Thu Nov 2 09:19:10 EST 2006


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982667#3982667

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3982667



More information about the jboss-user mailing list