Eclipse: Overriding JNDI Resource in Tomcat

你。 提交于 2019-12-05 08:06:02

The basic problem here is, that the context.xml you edit in eclipse corresponds to the main context.xml in the conf directory of tomcat. And then the preferences in the application context file takes precedence. As you already described within normal deployment lifecycle of tomcat this is perfectly fine, because you just edit the application settings.

You could do the same with the context file created by eclipse (which is located somewhere at .metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/Catalina/localhost) but it will be overwritten as soon as you change something in the original context file (META-INF/context.xml). So actually you would need to make the changes there, but this is normally out of question because this file must be deployed without custom changes.

But here is a workaround: You can make eclipse use another META-INF/context.xml by abusing the deployment assembly. Make a new META-INF directory somewhere else and place a context.xml file with your setting there. Then in the project properties of your eclipse project at Deployment Assembly add an additional mapping from your new path/to/META-INF to META-INF.
Then eclipse will overwrite the original context.xml with your custom one and tomcat should take your settings.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!