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
http://olafsblog.sysbsb.de/tomcat-5-und-crosscontext-konfiguration/
http://www.eclipse.org/forums/index.php/t/51881/
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
http://www.eclipse.org/forums/index.php/t/50640/
It's simple but not perfect:
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.
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 ;/
Related
I'm developing for Tomcat 8 under Eclipse Mars.
This is my application context in published server.xml:
<Context docBase="C:\automation\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\ROOT" path="" reloadable="false"/>
<Context docBase="AutomationWeb" path="/automation" reloadable="true" source="org.eclipse.jst.jee.server:AutomationWeb"/>
No other contexts defined there. But when I open tomcat manager app I see 2 contexts for my application:
One with "/AutomationWeb" path,
other with "/automation" path
My app has no context.xml
What I've discovered:
They share display name from my application's web.xml
My application can run on both paths.
The one with /AutomationWeb path is not actually reloadable
If I remove my application(Web Module) from Tomcat server in Eclipse, both entries disappear from tomcat manager app.
Deleting server in Eclipse and deleting contents of \workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\ didn't help.
How can I remove undesired application context with /AutomationWeb path? What configs should i check?
Solved it by changing publish directory from webapps to webappsauto. It seems the problem was in server.xml because of this statement:
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
I have a spring boot web application that deploys as a WAR. Right now when I deploy it to my Tomcat 7 server, it uses the name of the war file as the context, such as /myartifactid-1.5.4.SNAPSHOT/. I want to specify the context-path, but
server.contextPath=/mywebapp
seems to only work for embedded tomcat. I've added a META-INF/context.xml with only this
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="false" path="/mywebapp" />
but that hasn't had any effect.
EDIT: This is NOT a spring-boot issue, but instead related to how NetBeans behaves differently from Eclipse. NetBeans apparently recognizes the context path parameter in context.xml, but Eclipse doesn't. In Eclipse you have to modify the Web Projects Settings to set the context path.
Changing Tomcat context path of web project in Eclipse
Since you are packaging your Spring Boot application as a war (as opposed to a jar with an embedded tomcat container) the context path will be the name of the war.
For example if you name your packaged application mywebapp.war and you place it under Tomcat's webapps, it will be available under /mywebapp
when the war does not have the same name with the project, the application will not be accessible via the context path on the tomcat,
to fix this you need to go to the POM.xml change the name of package to match the context path name
server.servlet.context-path=/virtualcard
<groupId>com.test.csc.virtualcard</groupId>
<artifactId>virtualcard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>virtualcard</name>
then the war will be: virtualcard.war
I am using this tutorial and I did all the steps according to it. But I am stuck to the very end step that is
Build the project and deploy the war file in Tomcat. Start Tomcat and hit below URL.
URL: http://localhost:8080/springDemo-1.0/welcome.do
I done 'build project' in eclipse and I export the project as .war file to webapps of tomcat, but when I use the URL it says "HTTP Status 404" and "The requested resource (/springDemo-1.0/welcome.do) is not available." Please help
Better is to use m2e-wtp plugin for eclipse
Update site http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/
After install update maven configuration (Maven -> Update Configuration). Now you can simple add WAR project to Tomcat instance configured in Eclipse WTP.
More about using this -> https://docs.sonatype.org/display/M2ECLIPSE/WTP+mini+howto
Maybe try manually loading the project into Tomcat. Go to http://localhost:8080 and click on "Tomcat Manager". At the bottom, upload your WAR and hit "Deploy". You should then be able to click on the link in the table, add the "/welcome.do", and see your page.
If you are denied access to the Tomcat manager, you might have to update the tomcat-users.xml in your Tomcat's conf folder (for example, see below).
<role rolename="manager-gui" />
<user username="admin" password="password" roles="manager-gui" />
With the above, you can access the manager using admin/password.
I have an Eclipse Java web application that I am deploying to Tomcat 7 from within Eclipse 3.7. In my Eclipse server configuration at Servers > Tomcatv7-config > server.xml, I see the following line is added when I deploy my application:
<Context docBase="myapp" path="/myapp" reloadable="true" source="org.eclipse.jst.j2ee.server:myapp"/>
My question is this: is there any way for me to add a parameter to this <Context> element for a specific project?
What I need to do is add useHttpOnly=”false” in order for DWR to work properly in Tomcat 7. I understand the security risks with this, so please no lecture :)
You should be able to specify a context.xml in /META-INF/ within your WAR/Project which will trump the server.xml line:
In an individual file at /META-INF/context.xml inside the application
files. Optionally (based on the Host's copyXML attribute) this may be
copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to
application's base file name plus a ".xml" extension.
It's somehow related to Eclipse. For example:
<Host>
<Context docBase="foo" path="/foo" reloadable="true"
source="org.eclipse.jst.j2ee.server:foo" />
</Host>
Eclipse WTP adds the source attribute to the project-related <Context> element to identify the location of the source code associated with the context (thus, the actual project in the workspace which has been deployed to this server from inside Eclipse).
If you wondered about this due to a warning during Tomcat's startup, since Tomcat 6.0.16 any "unrecognized" XML tags and attributes in the context.xml or server.xml will produce a warning about it during the startup, although there's actually no means of a DTD.
Just ignore it. Tomcat shall work fine and Eclipse is happy with it. It won't occur in real production environment with a worthfully WAR file.