Java – Eclipse Build Path Nesting Errors

eclipsejavaservletstomcat

I'm working on a simple JSP/Servlet/Tomcat webapp for my class. The professor asked us to use a folder structure that is slightly different than the default dynamic web project structure. Rather than using the webcontent folder he wants all of our source code under src/main/java and src/main/webapp.

When I run the app my welcome file displays fine, but when I try to access my servlets I get:

 Http 500 SEVERE: Allocate exception for servlet InitDb

java.lang.ClassNotFoundException. I'm pretty sure it's a build path error. I have final/src on the build path but I am receiving the warning

"Cannot nest 'final/src/main/webapp/WEB-INF/classes' inside 'final/src'. To enable the    nesting exclude 'main/' from 'final/src'

enter image description here

I have this in my deployment assembly:

<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> 

When I exclude main/ the warning goes away, but it doesn't fix the problem. I would appreciate any advice. Thanks.

Best Answer

I had the same problem even when I created a fresh project. I was creating the Java project within Eclipse, then mavenize it, then going into java build path properties removing src/ and adding src/main/java and src/test/java. When I run Maven update it used to give nested path error.
Then I finally realized -because I had not seen that entry before- there is a <sourceDirectory>src</sourceDirectory> line in pom file written when I mavenize it. It was resolved after removing it.