You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Justin Alcorn <al...@ohioonline.net> on 1999/12/28 16:19:24 UTC
HELP! Environment Variables
I've asked this a couple of times, and I can't believe that I'm the only
one running into this...
I'm trying to use Java Servlets -> JDBC -> DB2 from IRIX. I have it
working using Apache+JServ by putting the environment variables into
jserv.properties as wrapper.env entries.
I added an 'intranet' context in server.xml as:
<Context path="/intranet" docBase="intranet"
defaultSessionTimeOut="30" isWARExpanded="true"
isWARValidated="false" isInvokerEnabled="true"
isWorkDirPersistent="false"/>
and in intranet/WEB-INF/web.xml:
<env-entry>
<env-entry-name>
DB2INSTANCE
</env-entry-name>
<env-entry-value>
db2inst1
</env-entry-value>
<env-entry-type>
java.lang.String
</env-entry-type>
</env-entry>
(and other variables, as needed)
The JDBC Driver load (Class.forName("COM.ibm.db2.jdbc.app.DB2Driver")
returns successfully, so I have my CLASSPATH correct, but the
getConnection (con =
DriverManager.getConnection("jdbc:db2:database","user","pass") returns a
cannot find appropriate driver message. When I got this same message on
JServ, the wrapper.env entries fixed the problem.
How can I A) look at my environment from the servlet and B) set my
environment for a servlet in tomcat? What am I doing wrong.
This is getting URGENT! Please HELP!
--
Justin Alcorn, Director of Network Applications
OhioOnline, Inc., Cleveland, OH
Re: HELP! Environment Variables
Posted by "Craig R. McClanahan" <cm...@mytownnet.com>.
At the moment, Tomcat does not provide a mechanism to access the
<env-entry> elements from your deployment descriptor, which requires a
special JNDI implementation to access them (per the Java2 Enterprise
Edition (J2EE) specification's rules). I understand that a modification to
Tomcat to do this is under development at ExoLab (http://www.exolab.org).
Hopefully, this can be integrated with Tomcat in the near future.
In the meantime, I handle this kind of situation in the following manner:
* Define a servlet called StartupServlet
in the web application descriptor.
* Do not map StartupServlet to any
URI path (so it cannot be invoked
by a user).
* Make the environment entries you have
listed below into servlet initialization
parameters for StartupServlet.
* Declare a <load-on-startup> element
for this servlet so that it gets loaded when
Tomcat is started.
* In the init() method of StartupServlet,
initialize your database connection(s) based
on the servlet configuration parameters.
* Store the initialized connection(s) as a
ServletContext attribute so that they
are available to other servlets and JSP
pages in this application.
This mechanism will be portable to any 2.2-compliant servlet container,
whether or not it supports the J2EE stuff.
Craig McClanahan
Justin Alcorn wrote:
> I've asked this a couple of times, and I can't believe that I'm the only
> one running into this...
>
> I'm trying to use Java Servlets -> JDBC -> DB2 from IRIX. I have it
> working using Apache+JServ by putting the environment variables into
> jserv.properties as wrapper.env entries.
>
> I added an 'intranet' context in server.xml as:
>
> <Context path="/intranet" docBase="intranet"
> defaultSessionTimeOut="30" isWARExpanded="true"
> isWARValidated="false" isInvokerEnabled="true"
> isWorkDirPersistent="false"/>
>
> and in intranet/WEB-INF/web.xml:
>
> <env-entry>
> <env-entry-name>
> DB2INSTANCE
> </env-entry-name>
> <env-entry-value>
> db2inst1
> </env-entry-value>
> <env-entry-type>
> java.lang.String
> </env-entry-type>
> </env-entry>
>
> (and other variables, as needed)
>
> The JDBC Driver load (Class.forName("COM.ibm.db2.jdbc.app.DB2Driver")
> returns successfully, so I have my CLASSPATH correct, but the
> getConnection (con =
> DriverManager.getConnection("jdbc:db2:database","user","pass") returns a
> cannot find appropriate driver message. When I got this same message on
> JServ, the wrapper.env entries fixed the problem.
>
> How can I A) look at my environment from the servlet and B) set my
> environment for a servlet in tomcat? What am I doing wrong.
>
> This is getting URGENT! Please HELP!
>
> --
> Justin Alcorn, Director of Network Applications
> OhioOnline, Inc., Cleveland, OH
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
Re: HELP! Environment Variables
Posted by Fernando Salazar <fe...@metatel.com>.
I assume you've also called newInstance(), and registered the driver, as in:
Driver driver = (Driver)
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
DriverManager.registerDriver(driver);
I can't remember if the registerDriver() is needed with DB/2 -- I believe
many drivers are self-registering -- but you definitely new to create an
instance of the driver.
I imagine that if the problem was the environment, you'd see some
UnsatisfiedLinkError exceptions when the driver attempts to locate the DB/2
binaries.
- Fernando
At 10:19 AM 12/28/99 -0500, you wrote:
>I've asked this a couple of times, and I can't believe that I'm the only
>one running into this...
>
>I'm trying to use Java Servlets -> JDBC -> DB2 from IRIX. I have it
>working using Apache+JServ by putting the environment variables into
>jserv.properties as wrapper.env entries.
>
>I added an 'intranet' context in server.xml as:
>
> <Context path="/intranet" docBase="intranet"
> defaultSessionTimeOut="30" isWARExpanded="true"
> isWARValidated="false" isInvokerEnabled="true"
> isWorkDirPersistent="false"/>
>
>and in intranet/WEB-INF/web.xml:
>
> <env-entry>
> <env-entry-name>
> DB2INSTANCE
> </env-entry-name>
> <env-entry-value>
> db2inst1
> </env-entry-value>
> <env-entry-type>
> java.lang.String
> </env-entry-type>
> </env-entry>
>
>(and other variables, as needed)
>
>The JDBC Driver load (Class.forName("COM.ibm.db2.jdbc.app.DB2Driver")
>returns successfully, so I have my CLASSPATH correct, but the
>getConnection (con =
>DriverManager.getConnection("jdbc:db2:database","user","pass") returns a
>cannot find appropriate driver message. When I got this same message on
>JServ, the wrapper.env entries fixed the problem.
>
>How can I A) look at my environment from the servlet and B) set my
>environment for a servlet in tomcat? What am I doing wrong.
>
>This is getting URGENT! Please HELP!
>
>
>
>--
>Justin Alcorn, Director of Network Applications
>OhioOnline, Inc., Cleveland, OH
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: general-help@jakarta.apache.org
=======================================
Fernando Salazar <fe...@metatel.com>
w -781-392-2514