tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yuval Schwartz <>
Subject Fwd:
Date Mon, 23 Nov 2015 13:38:15 GMT

I am using tomcat
Language: Java
development: Windows, NetBeans.
deployment: ec2 linux

I am still having trouble understanding/working with "path" and "docBase"
of context element.
I have two questions:

First of all, I have a context.xml file in the WEB-INF folder of my
application (call it "myApplication" henceforth) that looks like:

<Context path="">
<Resource name="jdbc/some_db" auth="Container"
        maxActive="100" maxIdle="30" maxWait="10000"
        username="blah" password="blahblah"
        logAbandoned="true" removeAbandoned="true"
        removeAbandonedTimeout="60" type="javax.sql.DataSource" />

My context path is set to the empty string because once I set up a domain
name it will be redundant to have both the application name and domain name
in the url (they are the same).

This works on my development environment.

When I deploy this to a linux server of an ec2 instance (on aws) I add a
line to the server.xml file (in tomcat/conf) under the <Host> element which
<Context path="" docBase="myApplication"/>

(If I don't add this element to the server.xml file then entering just the
domain in the url takes me to the Apache Tomcat "successful installation"
page rather than to the welcome page of myApplication).

First question:
Is this the correct way to set up tomcat so that my application has no
context path? Not sure if this leads to the "double deployment" problem or
not. When I open the tomcat manager I see two applications: one with path:
"/" and the other with path "/myApplication". (for some reason, I don't
have the option to "undeploy" the application with path: "/")

Second question:
The resource element within the context element of my context.xml file
(located in WEB-INF) specifies a url that is specific to my development (ie
local) environment.
When I deploy myApplication to the ec2 instance I would like the resource
element to have a different url attribute (since it will now be connecting
with a database on an aws server).
One way that I found to do this was to add to the context.xml file in the
tomcat/conf directory of my server. There I add a resource element (between
the existing context element) which is identical to the one above only with
a url attribute that points to the database hosted on aws.

This way, my application is able to connect with my database without me
changing any of the code in myApplication.
However, my Catalina.log file displays:
WARNING [localhost-startStop-1]
org.apache.catalina.core.NamingContextListener.add Resource Failed to
register in JMX: javax.naming.NamingException: Could not create resource
factory instance [Root exception is java.lang.ClassNotFoundException:

And my localhost.log file shows a nullpointerexception for the line in my
(Where ic is an InitialContext Object)

There are also problems in the deployed website with some of the code that
grabs data from the db (but some of the db related code works successfully).

Any insight or suggestions would be greatly appreciated.
I'm new to a lot of this (extremely new to deploying to a server).

Thank you

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message