Thank you for the Response, Tommy. I already had a classpathScope test as shown
in baha_baniya / exec-maven-plugin-sample / source / pom.xml — Bitbucket.
|
|
| |
baha_baniya / exec-maven-plugin-sample / source / pom.xml — Bitbucket
|
|
|
Just figured out - I have to run class after test-compile phase in which phase
test classes are generated. Bound exec:java to process-test-classes
(previously it was process-test-resources) and it worked.
Regards,
Baha
On Friday, 13 July 2018, 1:25:51 am AEST, Tommy Svensson
<[email protected]> wrote:
#yiv7925638447 body{font-family:Helvetica, Arial;font-size:13px;}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 <[email protected]>
Svara: Baha Baniya <[email protected]>
Datum: 12 juli 2018 at 14:24:23
Till: [email protected] <[email protected]>
Ä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: [email protected]
For additional commands, e-mail: [email protected]