I encounter a strange behaviour of the Eclipse Run on Server feature. My environment:
Eclipse Kepler SR 1, WTPApache Tomcat 7.0.37
I have two dynamic web projects inside Eclipse - ProjectA and ProjectB. Both have an index.xhtml file (indeed both projects are JSF projects) directly below the WebContent folder. When I export them as WARfiles to the Tomcat webapps folder of the Tomcat installation, both run fine. When I run ProjectA on the Tomcat server managed by Eclipse through Run on Server feature, everything is also fine. But when I want to start ProjectB from Eclipse through Run on Server I get a 404 error when accessing the http://localhost:8080/ProjectB/index.xhtml or respectively an index.xhtml Not Found in ExternalContext as a Resource error from the JSF servlet when accessing the resource through the correct http://localhost:8080/ProjectB/faces/index.xhtml URL. (All URLs starting with /faces/ are matched to the JSF Servlet.
Looking at the deployed application in the Tomcat folder in the Eclipse Workspace ( <eclipse-workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps) reveals the cause:
For ProjectB the content of the Eclipse projects WebContent folder has been deployed to the WEB-INF folder instead to the root folder of the projects deployment. The application server of course can not find the resource.
The question is - Why does the deployment fail and how can I avoid this?
I even checked the Deployment Assembly property of both projects inside eclipse. Both have the same (default) source-to-destination-folder mapping. Here is the content of the .settings\org.eclipse.wst.common.component file:
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="ProfileAndGroupManagementGUI">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="ProfileAndGroupManagementGUI"/>
<property name="java-output-path" value="/ProfileAndGroupManagementGUI/build/classes"/>
</wb-module>
Strange, isn´t it? Anyone any idea?
The line
tells
wstto package your sources to/WEB-INF/classes, that's what you don't want to do as this is a lib project. Changing it towill do the trick.