Trying to run mvn exec and getting mojo exception on plugin - java

So I am running
mvn exec:java -Dexec.mainClass=”com.utm.csc.HTMLParser” -Dexec.args=”http://www.simplehtmlguide.com”
for my Java project. It runs in Eclipse but with the command above, gives me the following errors:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building assignment1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) # assignment1 ---
[WARNING]
java.lang.ClassNotFoundException: ”com.utm.csc.HTMLParser”
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:281)
at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.064 s
[INFO] Finished at: 2016-01-24T16:17:21-05:00
[INFO] Final Memory: 9M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven- plugin:1.4.0:java (default-cli) on project assignment1: An exception occured while executing the Java class. ”com.utm.csc.HTMLParser” -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
This is an image of my paths
I am using OS X El Capitan on a 64-bit MacBook Air mid-2012. What am I doing incorrectly?

The error is that you are giving the argument incorrectly. Your command should be:
mvn clean compile exec:java -Dexec.mainClass=com.utm.csc.HTMLParser -Dexec.args=http://www.simplehtmlguide.com
Notice the lack of quotes. This can be hinted from the error message:
java.lang.ClassNotFoundException: ”com.utm.csc.HTMLParser”
means that somehow, Java searched for a class called ”com.utm.csc.HTMLParser” but it didn't find any, simply because it is actually named com.utm.csc.HTMLParser, without the quotes.

Don't forget to compile first. exec:java doesn't do it by default.
mvn clean compile exec:java -Dexec.mainClass=”com.utm.csc.HTMLParser” -Dexec.args=”http://www.simplehtmlguide.com”

Related

How to setup akka persistence project

I'm attempting to run the sample project from How to setup akka persistence project : https://developer.lightbend.com/start/?group=akka&project=akka-samples-persistence-dc-java
When I try to run the example using the command :
mvn exec:java -Dexec.mainClass="sample.persistence.multidc.ThumbsUpApp" -Dexec.args="cassandra"
I receive the error:
[INFO] --< com.lightbend.akka.samples:akka-sample-replicated-event-sourcing-java >--
[INFO] Building Akka replicated event sourcing multi dc sample 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) # akka-sample-replicated-event-sourcing-java ---
[WARNING]
java.lang.ClassNotFoundException: sample.persistence.multidc.ThumbsUpApp
at java.net.URLClassLoader.findClass (URLClassLoader.java:471)
at java.lang.ClassLoader.loadClass (ClassLoader.java:589)
at java.lang.ClassLoader.loadClass (ClassLoader.java:522)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:246)
at java.lang.Thread.run (Thread.java:834)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.426 s
[INFO] Finished at: 2021-07-25T20:52:54+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project akka-sample-replicated-event-sourcing-java: An exception occured while executing the Java class. sample.persistence.multidc.ThumbsUpApp -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Looking at the project source:
The package sample.persistence.multidc.ThumbsUpApp does not appear to exist. How to include the missing package sample.persistence.multidc.ThumbsUpApp ? Shouldn't this project execute without adding additional src code ?
It seems you are referencing a class name that doesn't exist in the project source.
You may use the following command instead.
mvn exec:java -Dexec.mainClass="sample.persistence.res.MainApp" -Dexec.args="cassandra"

The system cannot find the file specified while trying to install JAR with sources with Maven

I was using the followig command to build the project
mvn compile exec:java clean install
and it was working. I wished it to install sources to local repository and wrote
mvn compile exec:java source:jar clean install
and now it fails with
...
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing MYSOURCEPATH\target\my-library-1.12.1.jar with MYSOURCEPATH\target\my-library-1.12.1-shaded.jar
[INFO] Dependency-reduced POM written at: MYSOURCEPATH\dependency-reduced-pom.xml
[INFO] Dependency-reduced POM written at: MYSOURCEPATH\dependency-reduced-pom.xml
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # my-library ---
[INFO] Installing MYSOURCEPATH\target\my-library-1.12.1.jar to MYLOCALREPOPATH\MYLIBRARYPATH\1.12.1\my-library-1.12.1.jar
[INFO] Installing MYSOURCEPATH\dependency-reduced-pom.xml to MYLOCALREPOPATH\MYLIBRARYPATH\1.12.1\my-library-1.12.1.pom
[INFO] Installing MYSOURCEPATH\target\my-library-1.12.1-sources.jar to MYLOCALREPOPATH\MYLIBRARYPATH\1.12.1\my-library-1.12.1-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.280 s
[INFO] Finished at: 2018-02-26T18:38:23+03:00
[INFO] Final Memory: 46M/1373M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project my-library: Failed to install artifact my.library.fqn:my-library:jar:sources:1.12.1: MYSOURCEPATH\target\my-library-1.12.1-sources.jar (The system cannot find the file specified) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
how to fix/overcome?
Try
mvn clean source:jar compile install exec:java
Or just:
mvn clean source:jar install exec:java
So basically you need to put the "clean" before the "source:jar"
or else installation for sources will fail

MAVEN SUREFIRE PLUGIN ERROR

Im building a custom maven project for jenkins. After using the command
mvn -Plight-test install
I recieve this error .Please help. I have also added the plugin for surefire exception in the pom.xml file, but it isn't working! The error log is as follows :
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Jenkins main module ................................ SUCCESS [ 11.809 s]
[INFO] Jenkins cli ........................................ SUCCESS [ 38.319 s]
[INFO] Jenkins core ....................................... FAILURE [11:15 min]
[INFO] Jenkins war ........................................ SKIPPED
[INFO] Tests for Jenkins core ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:10 min
[INFO] Finished at: 2016-05-05T12:26:54+05:30
[INFO] Final Memory: 39M/277M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project jenkins-core:
.
[ERROR]
[ERROR] Please refer to C:\Users\Anishas\git\jenkins\core\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :jenkins-core
Compile :
I had the same issues and I found out that the problem was that some of tests tried to create a System link and it was not possible because I didn't start my IDE (IntellijIdea) as administrator in Windows.
I started Intellij as administrator and that solved the problem.
Skipping test is not a good practice when developing.
mvn -Dmaven.test.skip=true -DskipTests=true clean install
use this command
Rerun with mvn -Plight-test install -rf jenkins-core -X to isolate the error

Maven 3: Maven in 5 minutes "mvn archetype:generate..." command NOT WORKING

I installed Maven 3.1.1 for the first time. In the "Maven in 5 Minutes" getting-started guide
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
it says to verify the installation with
mvn --version
I got the expected response:
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 11:22:22-0400)
Maven home: C:\applications\programming\apache-maven-3.1.1
Java version: 1.6.0_17, vendor: Sun Microsystems Inc.
Java home: C:\applications\programming\java_6_17\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
In the next step, under "Creating a project" it says to create a new directory, open a command prompt in that directory, and execute
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
I created a directory called xjmaven, ran the command in it, and it's not working. This is the response:
[R:\jeffy\programming\sandbox\xjmaven]mvn archetype:generate -DgroupId=xbnjava -DartifactId=XBN-Java -Darchetype ArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.251s
[INFO] Finished at: Sat Nov 23 12:11:56 EST 2013
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (R:\jeffy\programming\sandbox\xjmaven). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
I looked up the parameters groupId, artifactId and archetypeArtifactId, and have tried some different values (as you can see above), but I still get the same BUILD FAILURE response.
I manually put the pom.xml file (from in the same webpage) in the xjmaven directory, and ran it again. It downloaded a bunch of stuff (although not to xjmaven), but then failed with this message:
[INFO] Generating project in Interactive mode
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/true/1.0/true-1.0.jar
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Maven Quick Start Archetype
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.047s
[INFO] Finished at: Sat Nov 23 12:04:01 EST 2013
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project XBN-Java: The desired archetype does not exist (org.apache.maven.archetypes:true:1.0) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Repeating the command gives this response:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) # XBN-Java >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) # XBN-Java <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) # XBN-Java ---
[INFO] Generating project in Interactive mode
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Maven Quick Start Archetype
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.444s
[INFO] Finished at: Sat Nov 23 12:04:32 EST 2013
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project XBN-Java: The desired archetype does not exist (org.apache.maven.archetypes:true:1.0) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I deleted pom.xml (it's the only file in the directory...the stuff it downloaded is not there), and started over again. Everything happens (badly) as I write above.
I remember trying Maven a few years ago, and could also not get past the getting-started stage.
If anyone has some advice on how to get past this, it would be appreciated. Really frustrated.
Maybe you are using Windows PowerShell?
If so, you'll need to put quotes around the parameter definitions:
mvn archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DgroupId=com.mycompany.app" "-DartifactId=my-app"
You have some syntactical errors while executing the generate goal. Moreover, you need not create the pom.xml or any dir sturcture. You will notice that the generate goal creates a directory with the same name given as the artifactId.
e.g. you are missing the convention like -DgroupId should be com.company.app (not a big issue though), having space in -Darchetype ArtifactId, etc.
I just tried below and it worked :
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
I was having a similar issue on powershell. I switched to command prompt and executed the same command and it works fine. Command that works on command prompt: mvn archetype:generate -DgroupId=com.myapp-DartifactId=hellomaven -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The one that runs on powershell:
mvn archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DgroupId=com.myapp" "-DartifactId=my-app"

Hibernate tutorial not working

I have been following the hibernate tutorial on http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html
and as others have pointed out in various web boards, it's incomplete.
When I run this command:
mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # hibernate-tutorial >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # hibernate-tutorial <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # hibernate-tutorial ---
[WARNING]
java.lang.ClassNotFoundException: org.hibernate.tutorial.EventManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:722)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.962s
[INFO] Finished at: Sun Sep 30 17:03:34 EDT 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (d
efault-cli) on project hibernate-tutorial: An exception occured while executing
the Java class. org.hibernate.tutorial.EventManager -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
So I think the problem is obvious. When maven executes java, java doesn't know where to find my 'EventManager'. I tried the following on my command line:
set CLASSPATH=C:\Users\robe\Documents\hibernate\project1\src\main\java\org
What else could be wrong here?
Thanks!
I think your classpath is wrong. Try
set CLASSPATH=C:\Users\robe\Documents\hibernate\project1\src\main\java
You don't need the org. That is part of the full qualified class name. The full class name is org.hibernate.tutorial.EventManager
I am not familiar with this tutorial's problem. You may get other classpath errors. If you do you can add more to the class path by separating them by a semi colon.
Also you are setting the classpath in the cmd line. It will only be set for that session so you will have to run your mavem command in the same one. Or set it in your global environment variables
Try running:
mvn clean install
I know it sounds obvious, but when I tried to execute
mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"
I get the same error as you did. But after running mvn clean install the app started (I ran clean install for this code https://github.com/stivlo/hibernate-tutorial, it looks it is the same thing)

Categories

Resources