Maven MojoExecutionException - java

I am facing this issue , when i am deploying my application using Maven, please suggest some solution.
Error log,
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.790s
[INFO] Finished at: Wed Apr 23 10:44:13 IST 2014
[INFO] Final Memory: 54M/131M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project clustering.services: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\lib\tools.jar -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :clustering.services
Thanks in advance.

set JAVA_HOME to jdk not to JDK_DIR/jre, See this question for how to set the value

If you're using Eclipse, go to Windows->Preferences.
Under Java->Installed JREs, double click on the item in the list and make sure the JRE home points to a JDK (for example, set it to "C:\Program Files\Java\jdk1.7.0_60"), and leave everything else the same.

Most of the time that i get this "Mojo" error. It is just because, i may have forgotten to do "Maven generate-sources" then "Maven Clean" prior to do the "Maven Install" or "Maven Build". The MojoExecutionException should not appear after that. Some Eclipse versions have this problem to refresh the target folder. In this case, Refresh the project just after the "Maven Install".
If not resolved yet, it could be a lot of things (failed to copy a file(s), missing file(s), etc). I would suggest that you run the Maven Install in debug mode by adding -X to get more details on what may have happened then check your log: Right click on project> Run As> Maven Build as the following screenshot:

Verify that the name of the main class to execute in the application is specified in the pom.xml.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.enterprise.mainPacket.MainApp</mainClass>
</properties>
Also check if the .fxml file has been relocated, so that it correctly addresses the controller associated with it. fx:controller="com.enterprise.mainPacket.FXMLController"
<VBox fx:id="vBMasterContainer" prefHeight="698.0" prefWidth="800.0" styleClass="theme" stylesheets="#/styles/style.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.enterprise.mainPacket.FXMLController">

I had the same error. I fixed the path to Java, and was missing the tools jar. I copied it from another place. After that, everything worked.

Check that there are no conflict on the port (another service already running) !

Make sure that you don't have any empty packages within your source code folder. If there aren't any classes, the same error will occur.

After I changed the version in pom.xml to 1.2.1, the error was resolved.

Related

Apache Flink with AWS Kinesis Analytics

The actual situation
I want to use Apache Flink with Kinesis Analytics. Like I don't have experience with Java and Maven and going to try to summary the steps I followed and the results.
Use IntelliJ IDEA as IDE
Test this example without any problems
Change to AWS, following their instruction. The problems start in the step: Create and Compile the Apache Flink Streaming Java Code
The problems
If you want to use the Kinesis connector, you can not do it like other connector due to the ASL license and they do not deploy the artifact to the Maven central repository on Flink releases, so you will need to build the Kinesis connector by yourself download the source code for the connector from here Apache Flink, and install it to your local Maven repository.
After download it, you have build the module following this steps:
mvn clean install -Pinclude-kinesis -DskipTests
So I move to the unziped folder, and run the mvn command, with this error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 50.670 s
[INFO] Finished at: 2018-12-27T14:35:13+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.rat:apache-rat-plugin:0.12:check (default) on project flink-parent: Too many files with unapproved license: 2 See RAT report in: C:\Users\...\flink-master\target\rat.txt -> [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 :flink-parent
Trying to find a solution, I tried what this user said here
mvn clean install -Pinclude-kinesis -DskipTests -Drat.ignoreErrors=true package
But again, I had an error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:15 min
[INFO] Finished at: 2018-12-27T14:40:47+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project flink-shaded-hadoop2: Could not resolve dependencies for project org.apache.flink:flink-shaded-hadoop2:jar:1.8-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path C:\Program Files\Java\jdk-11/../lib/tools.jar -> [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/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :flink-shaded-hadoop2
The questions
How should I build the connector module?
How should I install it to my local Maven repository?
After receiving similar errors, even after using the other answer's solution for checking out a release branch, I found a solution that works for me. According to the build guide in the Flink docs, you can also add the -Dfast option to speed up build time. In my case, this resolved the licensing errors:
mvn clean install -Pinclude-kinesis -DskipTests -Dfast
I think that the problem is that you're trying to build the "snapshot" build of the Flink connector, not the release build.
Since you're not familiar with Java and Maven, here's what that means: Maven differentiates between "snapshot" builds, which are currently under active development, and "release" builds. Normally a project only pushes its release builds to Maven Central. However, for long-running development, the "master" branch is often a snapshot.
The POM in your linked instructions references version 1.6.2, so that's what you should be building. Check out the tag release-1.6.2, and also make sure that you're reading the Flink documentation for that version (your link above is for the latest development version).

Angular7 + maven with IBM websphere error (frontend-maven-plugin:1.0:npm (npm install fail))

I have a complete angular7 project and want to integrate with java.
is there any way to do it?
I am using eclipse maven + ibm websphere. (not spring boot)
I referred this post(by #TimeTraveler) and tried to follow...
however when I run command mvn clean package, I encounter this error
[INFO] --- frontend-maven-plugin:1.0:npm (npm install) # angular7test ---
[INFO] Running 'npm install' in C:\Users\eclipse-workspace\angular7test\angular-project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:01 min
[INFO] Finished at: 2018-11-29T23:16:03+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm install) on project angular7test: Failed to run task: 'npm install' failed. java.io.IOException: Cannot run program "C:\Users\eclipse-workspace\angular7test\node_installation\node\node.exe" (in directory "C:\Users\eclipse-workspace\angular7test\angular-project"): CreateProcess error=267, The directory name is invalid -> [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
and I also have a question .. based on that post, maven project looks like below
Maven Project -
src
main
java
resources
webapp
WEB-INF
web.xml
angular-project (I paste my angular project here)
node_installation ========>what is this?????
pom.xml
what is node_installation? .. is that a folder? do i need to create?
this is my package..
The error you posted indicates that Maven can't find the node.js executable node.exe in order to build your Angular project. Make sure you configure your pom as indicated on the frontend-maven-plugin readme page so that it will install node and npm into your project dir where maven expects to find it. This will create the node_installation directory you are missing and populate it with the node.exe executable, which should resolve the error.

Jspresso 4.1-SNAPSHOT ViewTester

I am doing the reference guide tutorial. When saving changes in view.groovy i can see the building workspace message of eclipse but these changes are not shown in ViewTester until i do a mvn compile in core directory.
Is this the right behavior? Is it possible to see the changes in ViewTester without that explicit mvn compile in core directory?
My setup: Win7, jdk1.7.0_55, Eclipse Luna Service Release 2 (4.4.2), Jspresso Developer Studio from www.jspresso.org/external/updates/e44/
UPDATE: When using refId id:'contact' instead of reference 'contact', ref:'ContactInfo' mvn compile shows the following error:
[INFO] Scanning for changes : C:\jspdev\wstutorial\quickhr\core\src\main\dsl
[INFO] Detected a change on source C:\jspdev\wstutorial\quickhr\core\src\main\dsl\view.groovy. Sun May 31 17:59:40 CEST 2015 > Sun May 31 17:57:14 CEST 2015
NBR ERROR : 1
UR-Unresolved reference : "Company.pane" ask for <Company.contact.address> of type field
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.038s
[INFO] Finished at: Sun May 31 17:59:51 CEST 2015
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jspresso.maven:sjs-maven-plugin:4.1-SNAPSHOT:compile-sjs (generate-dsl-application) on project quickhr-core: SJS defined frontend / views is invalid.
[ERROR] NBR ERROR : 1
[ERROR] UR-Unresolved reference : "Company.pane" ask for <Company.contact.address> of type field
[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/MojoExecutionException
UPDATE2: As Vincent has told the refId 'contact', id:'contact' fixed the compilation error when using refid.
Cleaning project workspace does not help with the ViewTester problem. I have discovered that dsl-view.xml is updated in directory C:\jspdev\wstutorial\quickhr\core\target\generated-resources\dsl\de\aboware\quickhr\view when view.groovy is saved but not in directory C:\jspdev\wstutorial\quickhr\core\target\classes\de\aboware\quickhr\view and it seems that ViewTester is reading it from there. Running mvn compile updates the file in this directory (or copying by hand) then ViewTester finds the changes. Any idea why this not happens automatically?
UPDATE3: Maybe it is a eclipse/maven sourced problem. When i do a build clean after saving changes in view.groovy (with autobuild enabled) ViewTester gets the changes without explicit mvn compile on th console. It seems that not all required parts of the project are recompiled automatically after saving changes to view.groovy. Any hints for me?
UPDATE4: For every changes in groovy files i have to do a build clean to see that changes in ViewTester and in SwingStartup. I think it is more a problem of my eclipse version/setup than a problem of jspresso. I have bind a shortcut to build clean what helps somewhat to handle this.
UPDATE5: I have started from scratch 2 times (Kepler/Luna) both times with Jspresso 4.2-SNAPSHOT and checked that the resource directories are there - no success. When saving changes to groovy files the compile-sjs goal ist triggered and the spring xml files are updated in the target/generated-resources/dsl directory. But in the default output directory target/classes nothing happens. When i change a generated spring xml file by hand (from inside eclipse), the target/classes directory gets updated. I think eclipse does not recognise the generation of the spring xml files as a workspace change which has to be answered by an auto build. Maybe there has been something changed in M2E with newer eclipse versions. Should i give it another try with Juno? But i don't know if it makes much sence to use such an old release while Mars is RC2 already.
There was an error in the doc regarding the refId use. This has been fixed by now. The correct statement is :
refId 'contact', id:'contact'
Regarding the main problem, simply relaunching the ViewTester after saving the view.groovy file should be enough to reflect the change. No need to go through CLI. Reading you question, I can see that the Eclipse build is triggered so I presume that automatic build is on which is necessary for the change to appear.
Can you do a complete clean of the workspace (Project > Clean... > Clean all projects) and try again ? There are times when changes in the groovy dsl sources are not correctly detected by the incremental build.
UPDATE: Please make sure that target/generated-resources/dsl is correctly installed as a resource directory in the project. This should be achieved automatically by the JDS plugin registering build hooks in ME2.

Unable to locate command maven in project with spring boot

I'm trying to setup a simple java rest service with spring boot and maven and I've downloaded maven and have my pom.xml located in the same folder as src so it's
src & pom.xml -> main -> java -> hello
when I'm inside the hello folder and try to run maven clean package to build my jar file it says command maven not found.
I'm still relatively new to java web dev so making sure everything is configured correctly is difficult for me. I've downloaded maven but do I need to have the actual maven files in my project?
Any help is truly appreciated.
-Adam
UPDATE:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.124s
[INFO] Finished at: Fri Oct 04 11:47:08 PDT 2013
[INFO] Final Memory: 4M/89M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/adam419/Desktop/Programming/Java/dd-servlet/src). 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
Edit:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/adam419/Desktop/Programming/Java/dd-servlet/src/main/java/hello/GreetingController.java:[3,7] error: class Greeting is public, should be declared in a file named Greeting.java
[ERROR] /Users/adam419/Desktop/Programming/Java/dd- servlet/src/main/java/hello/Greeting.java:[3,7] error: duplicate class: hello.Greeting
[INFO] 2 errors
The pom.xml must be in the "root" folder.
/yourApp:
- pom.xml
- /src
- /main/java
...
- /test/java
...
Although you are making the mistake #Ralph has given in his answer, I don't think this mistake would give the error message you're getting. To me it sounds like you haven't installed maven correctly. The install steps are at the bottom of this page. Make sure you've followed the directions correctly.
The error you've added on says there's no pom at the directory you ran the command from. You need to run the command in the same directory that the "pom.xml" file is in.

Generating jar file using maven in db unit installation

I need to install db unit in my system. I have completed installing JDBC driver. i have downloaded junit-4.11.jar.
I have to generate the jar file into the directory.What is the correct method/step of doing this.AS per the link:
http://www.dbunit.org/building.html
i tried to run the command mvn from command line.
But i get the error
C:\Users\suvin>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.225s
[INFO] Finished at: Tue Nov 20 14:51:56 IST 2012
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
in this directory (C:\Users\suvin). Please verify you invoked Maven from the co
rrect 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/MissingProject
Exception
Any help would be appreciated
Is dbUnit dependency is included in the POM file, if so mvn install does what you are expecting it to do
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.4.3</version>
</dependency>
it seems C:\Users\suvin location doesn't have pom file, Before execute "mvn install" your command prompt should be in place where your POM file exist.
For your information.
Normaly from a source codes you can build(compile) it and get your jars. To build a source codes you can use either ant or maven which are some build tools in java. Source codes providers provide their source codes with build.xml or pom.xml or both. You could use your build technology to compile that java source and get jar from it.
you can learn ant and maven from the web

Categories