You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by JDawg72 <mr...@hotmail.com> on 2009/05/12 14:08:41 UTC

Virtual host configuration problems

I have to admit that I am new to application server administration, and being
a programmer, I have a new found respect for the administrators I work with.

That being said, I am having a problem configuring my web application to
load when I type  www.mydomain.com in my browser address bar.  My
application does work as long as I type www.mydomain.com/myapp for the url.  
I have tried changing my server.xml host context and WEB-INF/context.xml
with no luck.  The closest I get to this working is the application starts
to load but as soon as it gets to a point in the servlet where it is
referencing my formBean it stops loading the page.  When I look at the log I
notice that the first error fails to get the database resource need to build
the form.  Then of course I get jsp exceptions because the formBean failed
to initialize.  Below is the first line in of the first exception that is
thrown as well as my server.xml and META-INF/context.xml entries.  

I have been through several forum threads that are similar to this issue,
but I have had no luck translating the suggestions successfully, and have
yet to find out why it works as long as I qualify the context path in the
url.  Any help would be greatly appreciated.

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'null'

server.xml
<Server
    port="9999">
  <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener
className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <GlobalNamingResources>
    <Resource
      auth="Container"
      description="User database"
      name="UserDatabase"
      type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
  </GlobalNamingResources>
  <Service
      name="Catalina">
    <Connector
        port="9999"
        minSpareThreads="1"
        address="127.0.0.1"
        maxThreads="50"
        maxSpareThreads="3"
        connectionTimeout="30000"
        protocol="AJP/1.3">
    </Connector>
    <Engine
        defaultHost="mydomain.com"
        name="Catalina">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
      <Host
          appBase="/home/userId/public_html"
          name="mydomain.com">
        <Alias>www.mydomain.com</Alias>
        <Context
           
docBase="/usr/local/tomcat/apache-tomcat-5.5.26/server/webapps/admin"
            path="/admin"
            privileged="true"
            reloadable="true">
        </Context>
        <Context
           
docBase="/usr/local/tomcat/apache-tomcat-5.5.26/server/webapps/manager"
            path="/manager"
            privileged="true"
            reloadable="true">
          <ResourceEnvRef
            name="users"
            type="org.apache.catalina.UserDatabase"/>
        </Context>
        <Context
            docBase="/home/userId/public_html/myapp"
            path=""
            reloadable="true">
        </Context>
      </Host>    
    </Engine>
  </Service>
</Server>
META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myapp" docBase="myapp" reloadable="true"
crossContext="true">
   <Resource name="jdbc/mycon" auth="Container" type="javax.sql.DataSource"
             maxActive="40" maxIdle="5" maxWait="5000"
             username="user" password="password"
driverClassName="com.mysql.jdbc.Driver"
             removeAbandoned="true" removeAbandonedTimeout="3"
logAbandoned="true"
            
url="jdbc:mysql://www.mydomain.com:3306/database?autoReconnect=true" />
</Context>  
-- 
View this message in context: http://www.nabble.com/Virtual-host-configuration-problems-tp23501325p23501325.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: Virtual host configuration problems

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: JDawg72 [mailto:mr.j.l.j@hotmail.com]
> Subject: RE: Virtual host configuration problems
> 
> what has to happen when I need to add another
> domain and application to this instance of Tomcat?

A domain may have many webapps deployed for it.  Each domain also has to have one default webapp.  When you have multiple, independent domains, each will need its own <Host> element with a unique appBase setting.  Under each appBase, place the domain's default webapp in the ROOT directory (or use a ROOT.war file).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: Virtual host configuration problems

Posted by Hassan Schroeder <ha...@gmail.com>.
On Tue, May 12, 2009 at 10:13 AM, JDawg72 <mr...@hotmail.com> wrote:
>
> ... but what has to happen when I need to add another
> domain and application to this instance of Tomcat?

<http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html>

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


RE: Virtual host configuration problems

Posted by JDawg72 <mr...@hotmail.com>.
Thanks Chuck, that worked but what has to happen when I need to add another
domain and application to this instance of Tomcat?

Jeremy


Caldarale, Charles R wrote:
> 
>> From: JDawg72 [mailto:mr.j.l.j@hotmail.com]
>> Subject: RE: Virtual host configuration problems
>> 
>> >Your default webapp should be located in /home/userId/public_html/ROOT
>> -
>> nowhere else, and its ><Context> element >>should be in
>> /home/userId/public_html/ROOT/META-INF/context.xml.
>> Also I am not clear on the suggestion of using “ROOT”.
> 
> It's not a suggestion - it's a requirement.  The default webapp must be
> named ROOT, so change the name of the directory from myapp to ROOT (must
> be upper case).
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Virtual-host-configuration-problems-tp23501325p23506692.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: Virtual host configuration problems

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: JDawg72 [mailto:mr.j.l.j@hotmail.com]
> Subject: RE: Virtual host configuration problems
> 
> >Your default webapp should be located in /home/userId/public_html/ROOT
> -
> nowhere else, and its ><Context> element >>should be in
> /home/userId/public_html/ROOT/META-INF/context.xml.
> Also I am not clear on the suggestion of using “ROOT”.

It's not a suggestion - it's a requirement.  The default webapp must be named ROOT, so change the name of the directory from myapp to ROOT (must be upper case).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


RE: Virtual host configuration problems

Posted by JDawg72 <mr...@hotmail.com>.
Thanks for you reply Chuck,

I am using DailyRazor as my web hosting provider.  The operating system is
Linux kernel version 2.6.27.18-14, Tomcat version 5.5.26, and JVM is
1.5.0_15-b04.  This is a private JVM configuration provided by DailyRazor. 
I purchased this server configuration because I am planning on hosting more
then one application and domain with this instance of Tomcat.  I have read
in the Tomcat documentation and discovered the sections you mention about
context elements being located in the server.xml file, however this is the
configuration file I started with from my hosting provider.  With this
hosting provider they tell me that I do not have access to webapp directory
so I am assuming I need the two context descriptors for the admin and
manager Tomcat applications.  I will go ahead and remove all of the context
entries and put them in conf/Catalina/mydomain.com/

My context.xml file is in META-INF and not WEB-INF.  Sorry about the typo. 
I will make the you mentioned in my app contect.xml file.

>Your default webapp should be located in /home/userId/public_html/ROOT -
nowhere else, and its ><Context> element >>should be in
/home/userId/public_html/ROOT/META-INF/context.xml. 
Also I am not clear on the suggestion of using “ROOT”.

Jeremy

Caldarale, Charles R wrote:
> 
>> From: JDawg72 [mailto:mr.j.l.j@hotmail.com]
>> Subject: Virtual host configuration problems
>> 
>> That being said, I am having a problem configuring my web application
>> to load when I type  www.mydomain.com in my browser address bar.
>> My application does work as long as I type www.mydomain.com/myapp 
>> for the url.
> 
> If you're on a reasonably recent version of Tomcat, the default webapp
> must be named ROOT (case sensitive).
> 
> You didn't explicitly tell us the version of Tomcat you're using, although
> the config indicates it's probably 5.5.26; please confirm that, and let us
> know what JVM you're using and what OS.
> 
>> I have tried changing my server.xml host context and 
>> WEB-INF/context.xml with no luck.
> 
> The context.xml file belongs in META-INF, not WEB-INF; let's hope the
> above was a typo, since you do refer to META-INF later.
> 
>>         <Context
>> docBase="/usr/local/tomcat/apache-tomcat-5.5.26/server/webapps/admin"
>>             path="/admin"
>>             privileged="true"
>>             reloadable="true">
>>         </Context>
>>         <Context
>> docBase="/usr/local/tomcat/apache-tomcat-5.5.26/server/webapps/manager"
>>             path="/manager"
>>             privileged="true"
>>             reloadable="true">
>>           <ResourceEnvRef
>>             name="users"
>>             type="org.apache.catalina.UserDatabase"/>
>>         </Context>
>>         <Context
>>             docBase="/home/userId/public_html/myapp"
>>             path=""
>>             reloadable="true">
>>         </Context>
> 
> <Context> elements should not be placed in server.xml; that's extremely
> poor practice left over from older versions of Tomcat.  What you have
> above is a real mess; remove the <Context> elements from server.xml and
> place them where they belong.  For the webapps stored outside of the
> appBase directory (admin and manager), this should be
> conf/Catalina/mydomain.com/[appName].xml.  Your default webapp should be
> located in /home/userId/public_html/ROOT - nowhere else, and its <Context>
> element should be in /home/userId/public_html/ROOT/META-INF/context.xml.
> 
> Also note that if you have a single <Host>, it's not necessary to give it
> your domain name or supply any aliases; using the default of "localhost"
> will be fine.
> 
> I would configure an HTTP <Connector> to allow testing of Tomcat without
> the complication of using httpd in front of it.  (In fact, if you're not
> using httpd for something useful - such as PHP - get rid of it; it's only
> making things more complicated and slowing you down.)
> 
>> META-INF/context.xml
> 
> Where is the above directory located?
> 
>> <Context path="/myapp" docBase="myapp" reloadable="true"
> 
> The path and docBase attributes are not allowed when the <Context> element
> is in a webapp's META-INF/context.xml file.
> 
> Fix all of the above and see what happens.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Virtual-host-configuration-problems-tp23501325p23505238.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: Virtual host configuration problems

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: JDawg72 [mailto:mr.j.l.j@hotmail.com]
> Subject: Virtual host configuration problems
> 
> That being said, I am having a problem configuring my web application
> to load when I type  www.mydomain.com in my browser address bar.
> My application does work as long as I type www.mydomain.com/myapp 
> for the url.

If you're on a reasonably recent version of Tomcat, the default webapp must be named ROOT (case sensitive).

You didn't explicitly tell us the version of Tomcat you're using, although the config indicates it's probably 5.5.26; please confirm that, and let us know what JVM you're using and what OS.

> I have tried changing my server.xml host context and 
> WEB-INF/context.xml with no luck.

The context.xml file belongs in META-INF, not WEB-INF; let's hope the above was a typo, since you do refer to META-INF later.

>         <Context
> docBase="/usr/local/tomcat/apache-tomcat-5.5.26/server/webapps/admin"
>             path="/admin"
>             privileged="true"
>             reloadable="true">
>         </Context>
>         <Context
> docBase="/usr/local/tomcat/apache-tomcat-5.5.26/server/webapps/manager"
>             path="/manager"
>             privileged="true"
>             reloadable="true">
>           <ResourceEnvRef
>             name="users"
>             type="org.apache.catalina.UserDatabase"/>
>         </Context>
>         <Context
>             docBase="/home/userId/public_html/myapp"
>             path=""
>             reloadable="true">
>         </Context>

<Context> elements should not be placed in server.xml; that's extremely poor practice left over from older versions of Tomcat.  What you have above is a real mess; remove the <Context> elements from server.xml and place them where they belong.  For the webapps stored outside of the appBase directory (admin and manager), this should be conf/Catalina/mydomain.com/[appName].xml.  Your default webapp should be located in /home/userId/public_html/ROOT - nowhere else, and its <Context> element should be in /home/userId/public_html/ROOT/META-INF/context.xml.

Also note that if you have a single <Host>, it's not necessary to give it your domain name or supply any aliases; using the default of "localhost" will be fine.

I would configure an HTTP <Connector> to allow testing of Tomcat without the complication of using httpd in front of it.  (In fact, if you're not using httpd for something useful - such as PHP - get rid of it; it's only making things more complicated and slowing you down.)

> META-INF/context.xml

Where is the above directory located?

> <Context path="/myapp" docBase="myapp" reloadable="true"

The path and docBase attributes are not allowed when the <Context> element is in a webapp's META-INF/context.xml file.

Fix all of the above and see what happens.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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