I\'m using Tomcat 8.5.6 inside Eclipse 4.6.1. I have my web-app project/context foo
, which has a JAX-RS (using RESTEasy 3.1.0.CR3) endpoint of bar
,
Your link to Markus' answer on https://stackoverflow.com/a/22380248/1794485 allowed me to get this working, or at least as described in his workaround. But the remaining problem to solve was ordering.
As he said, you can workaround this by having a local copy of the META-INF/context.xml
somewhere else, and adding this folder to the Deployment Assembly
in the project properties of the Eclipse project.
This didn't pick up for me initially though. It looks like that while the Deployment Assembly
in the properties shows as sorted by name, in fact it has an order like any other path. When I then removed the src/main/webapp
entry (so the one containing the normal META-INF/context.xml
) and added it back in, this effectively moved it down the pecking order. The next Tomcat deploy and startup in Eclipse finally put my preferred copy of META-INF/context.xml
in .metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myapp\META-INF
If in doubt about the true sequence of that Deployment Assembly
path, have a look under your Eclipse project on the file system - at .settings\org.eclipse.wst.common.component
.
It appears that in order to get Eclipse+Tomcat to recognize the per-module context files, you have to go into the server configuration (double-click on the server) and turn on the Publish module contexts to separate XML files. This way Tomcat will use the specific context XML file you created. Otherwise it apparently puts them in conf/server.xml
and ignores the context-specific file you created.
There is still the problem that Eclipse regenerates this file each time you do a rebuild, destroying whatever JNDI variables you placed there. I'm trying to get the workaround in https://stackoverflow.com/a/22380248/421049 to work, but not yet succeeding. Anyone have any better ideas?
At least I'm able to reproduce a production environment now --- albeit temporarily, until the next rebuild.