Hello Baha,

You need a dependency to a jar containing the `np.com.bahadur.ExecTest` class.

According to: https://www.mojohaus.org/exec-maven-plugin/java-mojo.html the 
dependency should have scope ’runtime’ unless you set the ’classpathScope’ 
parameter to something else. 

Your pom has no dependencies at all.

Regards,
Tommy


Från: Baha Baniya <baha.ban...@yahoo.com.invalid>
Svara: Baha Baniya <baha.ban...@yahoo.com>
Datum: 12 juli 2018 at 14:24:23
Till: users@maven.apache.org <users@maven.apache.org>
Ämne:  Could not run main class in src/test/java due to ClassNotFoundException  

Hi

When I run mvn exec:java : 

I get error:

java.lang.ClassNotFoundException: np.com.bahadur.ExecTest
    at java.net.URLClassLoader.findClass (URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:270)
    at java.lang.Thread.run (Thread.java:748)





pom.xml 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>

    <modelVersion>4.0.0</modelVersion>
    <groupId>replicate</groupId>
    <artifactId>exec-sample</artifactId>
    <version>1.1.0-SNAPSHOT</version>

    <name>Baha Replicate</name>
    <description>replicate exec</description>


    <build>
        <plugins>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>generate-test-json-data</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>np.com.bahadur.ExecTest</mainClass>
                    <classpathScope>test</classpathScope>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>



project structure 




Full project here 
baha_baniya / exec-maven-plugin-sample / source / — Bitbucket

baha_baniya / exec-maven-plugin-sample / source /    — Bitbucket


How to fix this issue?


Regards,
Baha 


---------------------------------------------------------------------  
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org  
For additional commands, e-mail: users-h...@maven.apache.org

Attachment: signature.asc
Description: Message signed with OpenPGP using AMPGpg

Reply via email to