You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Konstantinis Evagelos (evagelos.konstantinis@intracom.gr)" <ev...@intracom.gr> on 2003/01/14 14:26:13 UTC

Jndi.properties file

Hi, 

I have an war file with one jsp page which  get some 
information from  a entity bean.

      Hashtable env = new Hashtable();
      env.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
      env.put("java.naming.provider.url", "jnp://localhost:1099");
      Context ctx = new InitialContext(env);

In my jsp i have inserted the above code for finding the entity bean, and it
works ok.



I want  this information not to be in a jsp but in a jndi.properties file(so
i can change it later),  so 
i have created one, and this file is at the same level with my jsp.

when i deploy the war  to Tomcat,  and want to get my entity bean I can't
find the Contex where my entity bean is.

Where can i put my jndi.properties file. 


Any ideas???


Vangos.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Jndi.properties file

Posted by Andrzej Jan Taramina <an...@chaeron.com>.
> when i deploy the war  to Tomcat,  and want to get my entity bean I can't
> find the Contex where my entity bean is.

I ran into the same problem with JBoss and Tomcat running in separate 
JVM's.

> Where can i put my jndi.properties file. 
> Any ideas???

Yup.....try something like this:

   Properties props = new Properties();
			
   props.load( servlet.getServletContext().getResourceAsStream( 
                      "/WEB-INF/classes/jndi.properties" ) );

   InitialContext ctx = new InitialContext( props );

Put your jndi.properties file in the  specified subdirectory and then use the ctx 
as normal for an Entity Bean.

However, I must comment on your using an Entity bean as a remotely 
accessible component being accessed by a servlet or JSP.  For scalable 
systems, this is a poor design practice.  Best to "hide" the entity beans behind 
a service-oriented session bean facade.


Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions
http://www.chaeron.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>