tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Using a context.xml file in <catalina home>/conf/Catalina/local/context.xml
Date Wed, 02 Nov 2016 15:01:46 GMT

I've a developed a simple servlet in Eclipse which is supposed to display a welcome message
stored in <apache home>/conf/Catalina/localhost/context.xml.

When I run the web application from Eclipse in a local Tomcat instance, I get the following

"javax.naming.NameNotFoundException: The name welcomeMessage is not bound to this Context"

The only way to prevent the above message from being displayed is to create a context.xml
file in
the project's META-INF directory. However, for my purposes, I need to store the context.xml
file outside of the project's WAR.

Any help with this issue would be much appreciated.




public class MyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public MyServlet() {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
		try {
			Context initCtx = new InitialContext();
			String welcMessage = (String) initCtx.lookup("java:comp/env/welcomeMessage");
		} catch (NamingException e) {


Here are the contents of the <catalina home>/conf/Catalina/localhost/context.xml file:


	 <Environment name="welcomeMessage" type="java.lang.String" value="Welcome to DEV - localhost!"


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message