RE: Tomcat with external JBoss (JNDI problems)...Workaround...

2002-11-25 Thread Andrzej Jan Taramina
I've come up with a workaround to the problem that Tomcat servlets can't seem to find 
the jndi.properties file and 
thus connect to an external JBoss server.

Hardcoding the properties works, but is ugly since then your code is tied to the 
specific location of the JBoss 
server.and thus requries code changes and a recompile to deploy elsewhere.

Michael's suggestion of putting the jndi info into the web.xml file would work, but 
has the disadvantage of being yet 
another detail that is not standard that deployers would have to look into.

My workaround let's you put your jndi.properties file into /WEB-INF/classes as you 
would expectand that's all you 
need do.  The code is quite simple:

Properties props = new Properties();

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

InitialContext  ctx = new InitialContext( props );

All it requires is that you have a reference to the servlet so you can do the 
getServletContext() call.  That was a bit of 
a PITA for me...since the jmx-console code did not pass this into the class that 
needed the JNDI context...but that 
was pretty easily fixed.

I still think it should read the jndi.properties file without this workaround!

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


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Tomcat with external JBoss (JNDI problems)...Workaround...

2002-11-22 Thread Andrzej Jan Taramina
I've come up with a workaround to the problem that Tomcat servlets can't seem to find 
the jndi.properties file and 
thus connect to an external JBoss server.

Hardcoding the properties works, but is ugly since then your code is tied to the 
specific location of the JBoss 
server.and thus requries code changes and a recompile to deploy elsewhere.

Michael's suggestion of putting the jndi info into the web.xml file would work, but 
has the disadvantage of being yet 
another detail that is not standard that deployers would have to look into.

My workaround let's you put your jndi.properties file into /WEB-INF/classes as you 
would expectand that's all you 
need do.  The code is quite simple:

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

All it requires is that you have a reference to the servlet so you can do the 
getServletContext() call.  That was a bit of 
a PITA for me...since the jmx-console code did not pass this into the class that 
needed the JNDI context...but that 
was pretty easily fixed.

I still think it should read the jndi.properties file without this workaround!

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


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]