Hello,

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 message:

"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.

Cheers,

Philippe


---------------------

@WebServlet("/MyServlet")
public class MyServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
       
    public MyServlet() {
        super();
    }


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

----------------------------------

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

-------------------------------------

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

------------------------------

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

Reply via email to