eclipsetomcateclipse-wtpcross-context

How to auto set crossContext in an Eclipse WTP Tomcat


How can I set the crossContext directive in the context of an web application so any WTP publish / deploy will set this correct to the generated Applications context.xml (conf/Catalina/localhost/appname.xml)

I tried to set it in the Servers context.xml as "default" but also generated a stub context.xml in the WEB-INF/context.xml of the web application, but nothing seems to help here ;/

The WEB-INF/context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context crossContext="true">
</Context>

Notes:

related to How to get a tomcat project path from different project in same tomcat by using java


Solution

  • It's simple but not perfect:

    1. After adding the module to tomcat via wtp, open the WTP Tomcat server.xml (typically located in your workspace > Servers > Tomcat vX.X Server at localhost) and add attribute crossContext="true" to the <Context> tag of the corresponding web-module.
    2. check "Publish module contexts to seperate XML files" in Tomcat WTP Frontend

    Positive side-effects: This will survive any "clean Tomcats working directory" or "clean project" actions

    (still) Negative: This will be overridden / removed if you change any WTP Tomcat options that affects server.xml like adding new modules, changing ports... After this action, you have to add it again. There is still NO frontend option as like for reloadable or ContextPath ;/