tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Parsons Technical Services" <parsonstechni...@earthlink.net>
Subject Re: Virtual Hosting & Database Pooling not working
Date Thu, 29 Apr 2004 11:34:14 GMT


Set useNaming to true.

Doug


----- Original Message ----- 
From: <muss@swiftdsl.com.au>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
Sent: Wednesday, April 28, 2004 1:01 AM
Subject: Re: Virtual Hosting & Database Pooling not working


> Hi,
> I have embeded my answers in your response, any ideas would be extremely
> greatful.
>
> Kindest Regards,
>     Matt Anderson
>
> > Matt,
> >
> > From what I understand the path for the context remains the same. It is
> > based on the data in the web.xml / context segments. This is the same
> > relative to the app no matter what the configuration is.
> >
> > I don't use the admin. I edit the files directly myself. Just a choice I
> > made.
> >
> > Did you restart Tomcat?
> >
> Yes many times
>
> > Does the app work otherwise?
> >
> Yes I can view the page. I can't view any information that is extracted
> from a database. I don't get a 500 error either.
>
> > What is the exact error you are receiving?
> >
> javax.naming.NameNotFoundException: Name java:comp is not bound in this
> Context
> at org.apache.naming.NamingContext.lookup(NamingContext.java:815)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:198)
> at javax.naming.InitialContext.lookup(InitialContext.java:347)
> at
>
dbconnection.DatabaseManager.getDatabaseConnection(DatabaseManager.java:57)
> at dbconnection.DatabaseManager.getStatement(DatabaseManager.java:70)
> at dbconnection.DatabaseManager.execute(DatabaseManager.java:80)
> at org.apache.jsp.mainpage_jsp.getCostCentres(mainpage_jsp.java:39)
> at org.apache.jsp.mainpage_jsp._jspService(mainpage_jsp.java:210)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> at
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
11)
> at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:284)
> at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:204)
> at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:257)
> at
>
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
> at
>
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:245)
> at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:199)
> at
>
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
> at
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184
)
> at
>
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
> at
>
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164
)
> at
>
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:149)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
> at
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:156)
> at
>
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
> at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
> at
>
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:732)
> at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
> at
>
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:688)
> at java.lang.Thread.run(Thread.java:534)
>
> Here is the code (line number beside them) that it is falling over on
>
> 54: try
> 55: {
> 56:   Context ctx = new InitialContext();
> 57:   DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/sun");
> 58:   return ds.getConnection();
> 59: }
> 60: catch(NamingException e)
> 61: {
> 62:   e.printStackTrace();
> 63:   return null;
> 64: }
>
> What gets me though is, this worked when under the localhost host. Now I
> have it under imprest.neahs.health.nsw.gov.au it does not work anymore. I
> have to be doing something wrong.
>
> > Do the logs show any errors?
> >
> Yes that is where I got the above error (but that is all the log shows)
>
> > Add logging to the virtual host.
> >
> what level logging do you recommend?
>
> > Does more than one app access the same database?
> >
> No this database is specific to this web app alone
>
> > How do you deploy you apps?
> >
> I deploy them using the manager that comes with tomcat, which update all
> the xml files.
>
> > Sorry for all the questions, but need a better picture of the setup and
> > problem to advise you. Do not see any errors in what you have so far.
> >
> > Doug
> >
> > ----- Original Message -----
> > From: <muss@swiftdsl.com.au>
> > To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> > Sent: Tuesday, April 27, 2004 11:30 PM
> > Subject: Re: Virtual Hosting & Database Pooling not working
> >
> >
> >> My apoligees,
> >> OS = Windows 2000 Server
> >> DB = Oracle 8i
> >> Tomcat Version = 5.0
> >> JDK = 1.4.2
> >>
> >> the following web.xml found in the WEB-INF directory of the web
> > application
> >>
> >> <?xml version="1.0" encoding="ISO-8859-1"?>
> >>     <!DOCTYPE web-app PUBLIC
> >>     "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> >>     "http://java.sun.com/dtd/web-app_2_3.dtd">
> >> <web-app>
> >>   <description>Sun DB Connection</description>
> >>   <resource-ref>
> >>       <description>DB Connection</description>
> >>       <res-ref-name>jdbc/sun</res-ref-name>
> >>       <res-type>javax.sql.DataSource</res-type>
> >>       <res-auth>Container</res-auth>
> >>   </resource-ref>
> >> </web-app>
> >>
> >> the following server.xml found in the conf directory
> >>
> >> <?xml version='1.0' encoding='utf-8'?>
> >> <Server>
> >>   <Listener
> > className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
> >>   <Listener
> >>
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
> >>   <GlobalNamingResources>
> >>     <Environment name="simpleValue" type="java.lang.Integer"
> >> value="30"/>
> >>     <Resource auth="Container" description="User database that can be
> >> updated and saved" name="UserDatabase"
> >> type="org.apache.catalina.UserDatabase"/>
> >>     <ResourceParams name="UserDatabase">
> >>       <parameter>
> >>         <name>factory</name>
> >>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>pathname</name>
> >>         <value>conf/tomcat-users.xml</value>
> >>       </parameter>
> >>     </ResourceParams>
> >>   </GlobalNamingResources>
> >>   <Service name="Catalina">
> >>     <Connector acceptCount="100" connectionTimeout="20000"
> >> disableUploadTimeout="true" port="80" redirectPort="8443">
> >>     </Connector>
> >>     <Connector port="8009" protocol="AJP/1.3"
> >> protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
> >> redirectPort="8443">
> >>     </Connector>
> >>     <Engine defaultHost="localhost" name="Catalina">
> >>       <Host appBase="webapps" name="localhost">
> >>         <Logger className="org.apache.catalina.logger.FileLogger"
> >> prefix="localhost_log." suffix=".txt" timestamp="true"/>
> >>       </Host>
> >>       <Host appBase="E:\imprest\public"
> >> name="imprest.neahs.health.nsw.gov.au">
> >>       </Host>
> >>       <Logger className="org.apache.catalina.logger.FileLogger"
> >> prefix="catalina_log." suffix=".txt" timestamp="true"/>
> >>       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
> >>     </Engine>
> >>   </Service>
> >> </Server>
> >>
> >> the following ROOT.xml found in the
> >> conf\Catalina\imprest.neahs.health.nsw.gov.au directory
> >>
> >> <?xml version='1.0' encoding='utf-8'?>
> >> <Context docBase="E:/imprest/public" path="/" useNaming="false">
> >>   <Resource name="jdbc/sun" type="javax.sql.DataSource"/>
> >>   <ResourceParams name="jdbc/sun">
> >>     <parameter>
> >>       <name>url</name>
> >>       <value>jdbc:oracle:thin:@14.28.4.56:1521:sundb</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>maxIdle</name>
> >>       <value>2</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>maxActive</name>
> >>       <value>4</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>driverClassName</name>
> >>       <value>oracle.jdbc.driver.OracleDriver</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>maxWait</name>
> >>       <value>-1</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>removeAbandoned</name>
> >>       <value>true</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>username</name>
> >>       <value>SUN</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>factory</name>
> >>       <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>logAbandoned</name>
> >>       <value>true</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>removeAbandonedTimeout</name>
> >>       <value>60</value>
> >>     </parameter>
> >>     <parameter>
> >>       <name>password</name>
> >>       <value>password</value>
> >>     </parameter>
> >>   </ResourceParams>
> >> </Context>
> >>
> >>
> >> I was using the admin web app to do the host/context/data source
> >> modifications however when I attempt to reference the data source to
get
> >> the db connection object I get a NamingException however when this was
> >> all
> >> within the default host of localhost it worked fine. I am suspecting
> >> that
> >> there is a different path for a virtual host when doing the
> >> context.lookup(). I hope I provided enough information. Thanks again
for
> >> your time and I look forward to hearing your responses.
> >>
> >> Kindest Regards,
> >>     Matt Anderson
> >>
> >>
> >> > Okay, lets get a few basics first.
> >> > OS
> >> > Platform
> >> > Tomcat version
> >> > JDK version
> >> >
> >> > Post your server.xml
> >> >
> >> > Then we can proceed from there.
> >> >
> >> > Doug
> >> > www.parsonstechnical.com
> >> >
> >> >
> >> > ----- Original Message -----
> >> > From: <muss@swiftdsl.com.au>
> >> > To: <tomcat-user@jakarta.apache.org>
> >> > Sent: Tuesday, April 27, 2004 7:42 PM
> >> > Subject: Virtual Hosting & Database Pooling not working
> >> >
> >> >
> >> >> Hello all, I seem to be having a problem with virtual hosting and
> >> >> database
> >> >> pooling. I originally had the context for a website all within the
> >> >> default
> >> >> host, I put some datasources in there to connect to an oracle
> >> database.
> >> >> This worked great however I recently put a new domain on and
> > implemented
> >> >> virtual hosting, so I moved the datasource into the new host for
that
> >> >> domain. Now I seem to be getting a naming exception when I attempt
to
> >> >> reference it. Here is some snippets of code: -
> >> >>
> >> >> //This is where I originally gained a reference to
> >> >> //the data source and this worked fine
> >> >>   try
> >> >>     {
> >> >>       Context ctx = new InitialContext();
> >> >>       DataSource ds =
> >> (DataSource)ctx.lookup("java:comp/env/jdbc/sun");
> >> >>       return ds.getConnection();
> >> >>     }
> >> >>     catch(NamingException e)
> >> >>     {
> >> >>       e.printStackTrace();
> >> >>       return null;
> >> >>     }
> >> >>
> >> >>
> >> >> I have pretty much the same information in the ROOT.xml regarding
the
> >> >> resources, here is the header info of it.
> >> >>
> >> >>   <Resource name="jdbc/sun" type="javax.sql.DataSource"/>
> >> >>   <ResourceParams name="jdbc/sun">
> >> >>
> >> >> The web.xml file has not changed as I didn't see any need to.
> >> >>
> >> >> Does the lookup have to reference elsewhere once virtual hosting has
> >> >> been
> >> >> implemented? I really look forward to your responses as I seem to be
> >> a
> >> >> little confused as to why this is not working.
> >> >>
> >> >> Thanks for your time and I look forward to hearing from you.
> >> >>
> >> >> Kindest Regards,
> >> >> Matt Anderson
> >> >>
> >>
>> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >> >> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >> >
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message