tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Burbidge <mburb...@adobe.com>
Subject Where to define Context element...
Date Tue, 29 Apr 2008 15:05:24 GMT
I'm trying to define a JNDI resource for a datasource. The Tomcat  
documentation lists several different places that you can define a  
Context element. I don't want to define it in my app's web.xml and I  
don't want to modify tomcat config files. I want to define a companion  
file for my app, but I'm having a hard time understanding the  
documentation. It says the following, is one place you can define a  
Context element:

in individual files (with a ".xml" extension) in the $CATALINA_HOME/ 
conf/[enginename]/[hostname]/ directory. The name of the file (less  
the .xml) extension will be used as the context path. Multi-level  
context paths may be defined using #, e.g.context#path.xml.

My web app is in a war called mytest.war, which I deployed to  
$CATALINA_HOME/webapps. My web.xml has the following elements:

	<servlet>
		<servlet-name>mytest</servlet-name>
		<servlet-class>
			org.springframework.web.servlet.DispatcherServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>mytest</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

I placed a file named mytest.xml in $CATALINA_HOME/conf/Catalina/ 
localhost/mytest.xml. mytest.xml contains the following:

<Context path="/mytest" docBase="mytest"
         debug="5" reloadable="true" crossContext="true">

   <Resource name="jdbc/mytest" auth="Container"  
type="javax.sql.DataSource"
                maxActive="100" maxIdle="30" maxWait="10000"
                username="javauser" password="javadude"  
driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost:3306/mytest? 
autoReconnect=true"/>

</Context>

My Context defined this way is not loaded. I've checked using the  
Tomcat Manager and there is no JNDI resource loaded. What am I doing  
wrong?

Thanks,
Michael-


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