[jboss-user] [EJB 3.0] - Re: EJB 3.0 String injection at deploying time?

Marco.Pehla do-not-reply at jboss.com
Fri Dec 8 08:57:55 EST 2006


Thank you for your reply.

Today I tested some things and after all I installed the a new version of JBoss 4.0.5.


  | javax.naming.NameNotFoundException: env not bound
  | 

So that tells me that the env namespace is not bound, but why? And how to solve? Maybe JBoss doesn't find the jndi.properties file and this is the reason why it can't bound the right classes to the JBoss naming service? 

Here my EJB3: (after packaging inside the jar in the r2ml folder)

  | ...
  | @Stateless
  | @WebService
  | public class Webservice 
  | implements WebserviceInterface {
  | 	
  |  public Webservice() {} 
  | 	
  |  @WebMethod
  |  public String translate(String sourceLanguage, String targetLanguage,  String xmlInput) {
  | 		
  |  try {
  |   javax.naming.Context initContext = new javax.naming.InitialContext();
  |   javax.naming.Context compEnv = (javax.naming.Context) initContext.lookup("java:comp/env");
  |   String str = "String: ";
  |   str += (String) compEnv.lookup("translationURL");
  |   System.out.println(str);
  |  } catch (Exception e) {
  |   System.out.println(e.toString());
  |  }//try-catch()
  |  
  |  return new Translator().translate(sourceLanguage, targetLanguage, xmlInput);
  | }//translate()
  | ...
  | 

ejb-jar.xml : (after packaging inside the jar in the META-INF folder)

  | ...
  | <enterprise-beans>
  | 		<session>
  | 			<ejb-name>Webservice</ejb-name>
  | 			<ejb-class>r2ml.Webservice</ejb-class>
  | 			<env-entry>
  | 				<env-entry-name>translationURL</env-entry-name>
  | 				<env-entry-type>java.lang.String</env-entry-type>
  | 				<env-entry-value>http://localhost/translations/</env-entry-value>
  | 			</env-entry>
  | 		</session>
  | 	</enterprise-beans>
  | ...
  | 

jndi.properies (->after packaging the EJB jar, this file is in the same directory than the class files )


  | java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
  | java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
  | java.naming.provider.url=localhost:1099
  | 



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

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



More information about the jboss-user mailing list