'NoClassDefFoundError on Maven dependency if target folder is not present

Currently my NetBeans 8.0 has been doing the strangest thing.

I have a multimodule project. Usually I did not even have to have the projects opened or even downloaded, if the modules were in maven repository. Currently, some of my modules however need to be opened and built, so that "target" folder is in the project directory filled with classes. If it is not, I get a NoClassDefFoundError.

The error looks like this:

Exception in thread "main" java.lang.NoClassDefFoundError: SOME/CLASS/THAT/IS/EXPECTED/IN/TARGET/FOLDER/OF/SOME/MODULE/THAT/IS/A/DEPENDENCY
at ...
Caused by: java.lang.ClassNotFoundException: com.example.SOME.CLASS.THAT.IS.EXPECTED.IN.TARGET.FOLDER.OF.SOME.MODULE.THAT.IS.A.DEPENDENCY
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more

My POM looks like this:

<parent>
    <groupId>some</groupId>
    <artifactId>parent</artifactId>
    <version>0.9-SNAPSHOT</version>
</parent>

<scm>
    <developerConnection>scm:svn:https://someconnection</developerConnection>
</scm>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <tagBase>sometagbase/tags</tagBase>
            </configuration>
        </plugin> 
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
    <dependency>
        <groupId>myModuleGroupId</groupId>
        <artifactId>somModule1</artifactId>
        <version>1.2.1-SNAPSHOT</version>
        <type>jar</type>
    </dependency>
      ...... many of these here
</dependencies>

Why does it suddenly require a target folder with classes? Is it not supposed to get them from the dependencies? From the repository?



Solution 1:[1]

Open maven tab at right side of the editor and run double click all options of life cycle and try to see if folder finally generated

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jaime Román Gil