Accepted 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.


make two folders: final/src/ to store the source java code, and final/webroot/.

you cannot put the source and the webroot together. i think you may misunderstand your teacher.


for eclipse compiler to work properly you need to remove final/src from the source path and add final/src/main/java instead. this may also solve your problem as now the build directory won't be inside the java source folder.


sts ide

it depends on which folder one is telling "use as source folder" to. in the structure on the picture if one says it to the folder "target" or "generated", he gets the "nested" error. but on "cxf" folder, which is the last, mentioned in the pom.xml's 'plugin' section and where from the package structure begins (as shown on .wsdl file), i.e. - the right folder to do it 'source' one, then there is no error


this started taking me down a huge rabbit hole of fixing glitches with eclipse, however i just deleted the project from eclipse and reimported it to fix it.


got similar issue. did following steps, issue resolved:

  1. remove project in eclipse.
  2. delete .project file and . settings folder.
  3. import project as existing maven project again to eclipse.


you have to separate your sources and your target directory where the build output goes. it's also important to note that no class files ever can end up in the source directory. this is not against your professor's advice - actually he's promoting the maven standard source structure going for ./src/main/java and ./src/main/webapp. the second one should hold eg. the mandatory web-inf/web.xml file but you will never put actual classes there.

what you need to change is your target directory. i suggest going with the same standards and choosing the name "./target" for this. all the built files will go in here and packaging that up will result a correct deployable artifact. should you migrate to using maven later, it'll also help doing this in a scripted, repeatable way.

hope that clears up your issue.


the accepted solution didn't work for me but i did some digging on the project settings.

the following solution fixed it for me at least if you are using a dynamic web project:

  1. right click on the project then properties. (or alt-enter on the project)
  2. under deployment assembly remove "src".

you should be able to add the src/main/java. it also automatically adds it to deployment assembly.

caveat: if you added a src/test/java note that it also adds it to deployment assembly. generally, you don't need this. you may remove it.


in my case i have a gradle nature project in eclipse, the problem was in a build.gradle, where this sourcesets is specified:

sourcesets {
    main {
        java {
            srcdir 'src'

this seems to works well with intellij,however seems than eclipse doesn't like nest src, src/java, src/resources. in eclipse i must change it to:

sourcesets {
    main {
        java {
            srcdir 'src/main/java'


i had the same issue and correct answer above did not work for me. what i did to resolve it was to go to build path->configure build path and under the source tab i removed all the sources (which only had one source) and reconfigured them from there. i ended up removing the project from eclipse and import the maven project again in order to clear up the error.


try this:

from the libraries tab:

eclipse -> right click on project name in sidebar -> configure build path -> libraries

remove your web app libraries:

click on "web app libraries" -> click "remove"

add them back in:

click "add library" -> click to highlight "web app libraries" -> click "next" -> confirm your desired project is the selected option -> click "finish"

highlighting "web app libraries":

highlighting "web app libraries"


here is a simple solution:

  1. right click the project >> properties >> build path;
  2. in source tab, select all the source folders;
  3. remove them;
  4. right click on project, maven >> update the project.


i wanted to throw in a non-mavenish answer to this thread.

due to version control and strict directory structure reasons, i was unable to follow acheron's answer (the best answer) of doing something similar to removing src/ and adding src/main/java and src/test/java to the build path.

i had actually been off-and-on battling this nested build path issue for a couple weeks. the answer to the problem is hinted in the error message:

to enable the nesting exclude 'main/' from 'final/src'


in your build path, you need to edit your inclusion and exclusion patterns by clicking on excluded: (none) and then edit...:

  1. go to the navigator and press right click on the project
  2. build path
  3. configure build path
  4. source (tab)

exclusion patterns

there you can add main/webapp/web-inf/classes as an exclusion pattern. then it should allow you to add main/webapp/web-inf/classes to the build path as a separate source folder.

Related Query

More Query from same tag