Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317534 - Eclipse + Tomcat ignores META-INF/context.xml
Summary: Eclipse + Tomcat ignores META-INF/context.xml
Status: RESOLVED WORKSFORME
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: jst.server (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Larry Isaacs CLA
QA Contact: Angel Vera CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-21 18:48 EDT by Graham Leggett CLA
Modified: 2011-04-07 13:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Graham Leggett CLA 2010-06-21 18:48:26 EDT
Build Identifier: 20100218-1602

According to the FAQ at http://wiki.eclipse.org/WTP_Tomcat_FAQ, a context.xml file placed within the META-INF/ directory in the war will be used as the context for the application when tomcat is loaded by eclipse.

This however doesn't work.

To reproduce:

- Place a context.xml within the META-INF directory within a war project.
- Unpack a pristine copy of apache-tomcat v6.0.26.
- Add a tomcat 6.0 server, point it at the prisine copy.
- Add the war project to the list of tomcat projects.
- Start up tomcat, and hit a test URL showing the <Environment> entries from the servlet context. These show the default entries from the servlet, the parameters in context.xml are ignored.

As a result, you have to hack at the war web.xml file to get temporary parameters into the servlet while developing, which is very ugly.


Reproducible: Always

Steps to Reproduce:
xxx
Comment 1 Angel Vera CLA 2010-07-14 15:15:32 EDT
Try taking a look at Bug# 215228, hope it helps. If not Larry, should be able to assist you with more info.
Comment 2 Larry Isaacs CLA 2010-07-15 09:16:59 EDT
A simple test works for me.  Check the server.xml down under "<workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp?/conf" and see if the <Context> it contains for your project includes your <Environment> element(s).
Comment 3 Ronald van Kuijk (kukeltje) CLA 2011-02-10 07:45:25 EST
A simple test for me does not work. My context.xml in META-INF contains

<Context path="/my-context-path" debug="0">

<Resource name="jdbc/GoDocumentDB" auth="Container" type="javax.sql.DataSource" removeAbandoned="true"
   removeAbandonedTimeout="30" maxActive="10" maxIdle="30" maxWait="10000" username="godoc"
   password="godoc" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/my-app" validationQuery="select 1 from dual"/>

  
</Context>

The complete resource element is 'ignored' (have not tried other elements). It makes no difference if I use the option to have separate files or have it integrated in the server.xml. In both cases I see a 

<Context docBase="/home/user1/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/my-app-webapp" path="/my-app-webapp" reloadable="true" source="org.eclipse.jst.j2ee.server:my-app-webapp"/>
Comment 4 Larry Isaacs CLA 2011-02-10 09:19:36 EST
The server.xml under the Servers project in your workspace is unaffected by an META-INF/context.xml in your project.  It is the "merged" server.xml or context XML created during publishing (appears under the ".metadata\.plugins\org.eclipse.wst.server.core\tmp?\conf" directory by default) that should contain the child <Resource>.  Is that what you are looking at?
Comment 5 Larry Isaacs CLA 2011-04-07 13:27:25 EDT
Marking as WORKSFORME since the last question remains unanswered.  I'm assuming that the context.xml content was expected to appear in the server.xml found under the Servers project.  The content is actually merged during publishing and only appears in the published server.xml or separate context XML file for the context.