I got a maven spring project but when I try to run it, I can't... some idea about it...
The next is the Error Message:
BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.532s
Finished at: Wed Jul 26 16:04:06 COT 2017
Final Memory: 17M/196M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce
(enforce-versions) on project SIMI: Some Enforcer rules have failed. Look above for
specific messages explaining why the rule failed. -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
one thing that may cause this problem is that in your project in a POM file required java or maven version is set. you should find it... but how ?
maybe you couldn't find any enforcer in your project like me ...
(I had the same problem and I became confused because enforcer plugin was not defined in my projects POMs, so I couldn't find it).
enforcer plugin is in your "effective pom" and you should check it.
Effective pom is a configuration file made from super pom + project pom.
maven use this configuration file to execute the relevant goal. It helps developers to specify minimum configuration detail in his/her pom.xml. Although configurations can be overridden easily.
For showing your effective pom there are 2 ways:
1- use maven command, run this command :
mvn help:effective-pom
2- use your IDE : in Maven window right click on your project node and select show effective POM(it depends on your IDE).
after you find what your forces are you can find it in your project and change it.
for me, My effective POM had enforcer plugin which its requireMavenVersion rule for using Java was 1.8. so I changed my project JDK version to 1.8 and luckily the problem was solved.
I hope this answer could help you.
You should solve the root cause of the issue, conflict between some of your dependecies, mvn/java version, there is a lot of possible reasons.
You might run mvn dependency:tree and check in the list if there is maybe 2 different versions or implementations of the same library from different package. Often you will have a parent pom or a dependency somewhere in the framework uncompatible with one that you added into your pom.
But often, despite this enforcer error your project could build and run perfectly so this is a workaround to build ignoring the error
To skip enforcer (not always working)
mvn clean install -Denforcer.skip=true
To continue the build if error
mvn clean install -Denforcer.fail=false
There is probably some ways to exclude a specific library from the enforcer rules too which is probably better that juste skipping everything.
If you are using version 1.4.1 of maven-enforcer-plugin and it is resulting in this error then you need to use an older version of maven-enforcer-plugin. You can find the Maven dependency below :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
</plugin>
Other versions can be found from the link below.
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin
Also, check your Maven version. If you are using maven 3.0.x then you need to use maven-enforcer-plugin 1.4.1.
It is possible that someone is enforcing a specific Maven version.
If you see the following message:
[WARNING] Rule 0:
org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Detected Maven Version: 3.5.4 is not in the allowed range [3.5.2,3.5.2].
Then change your maven installation to the something in the specified range.
In this example, only version 3.5.2 is allowed.
This error is likely caused due to a mismatch of the java version specified in the pom file and the java in your system. I had Java 16 installed in my system but the pom pointed to java version 8.
There are 2 ways to solve this:
Update the java version in the pom file to the java version installed on your PC, but this will likely cause a lot of dependency issues.
Uninstall java installed in your system, and reinstall the java version specified in the pom file. You can do this by following the steps mentioned below:
Check the java version in your system with the following command:
java -version
And then check the java version defined in your pom file. It'd be something like
<project.java.version>1.8</project.java.version>
Install JDK 8.
I had this problem because Java (java) was version 8 and the Java compiler (javac) was version 11.
This is typical for Windows users, if you need to switch between versions manually.
Please check the versions first:
java -version
javac -version
If an IDE is used, for example an IntelliJ Idea, then I will advise to carefully study the project settings as well. Perhaps it makes sense to completely delete the files generated by the IDE and import the project again.
I faced the same issue and resolved it by fixing the pom versions. Below command didn't run properly on all the sub pom's which resulted in different pom versions.
'mvn versions:set -DnewVersion=${NEW_VERSION} versions:commit'
Check whether all the moms have same version if there is dependent pom's.
After doing some research found an answer for this .if your using IntelliJ
Go to Settings ---> builds --> Maven -->set the Maven home directory.
I faced this issue. Its because of the maven binary version used.
I have used maven 3.0.3 version. and the enforcer plugin wasn't reliable with that. So changed the maven binary to latest 3.6.3. And the issue got resolved and working awesome.
Firslty go tto project and run mvn clean , if build is success then just check whether the required dependency is downloaded in your .m2 folder or not , If dependency does not get downloaded in your local .m2 folder , it means either version number is incorrect for that dependency or artifactory path is not correct
Else if mvn clean itself fails while dependency exist in your .m2 folder , means yoru settings.xml file actually got corrupted
You should probably check if you have two different versions of same artifact somewhere. I faced it when I wanted to add new maven dependency while I already added it on a different dependent project with different versions.
Check your maven version, for example, if you are installing Apache-CXF 3.6 and your maven version is 3.0.5, then you get errors. If you're installing Apache-CXF 3.6, the minimun version of maven must be 3.1, and the minimun version of Java must be 8.
In my case, apparently there was a configuration conflict that generated this error. So when I temporarily deleted the /home/myuser/.m2/settings.xml file, the per-line maven execution was successful.
Note: In my scenario, I had Eclipse with the maven plugin and I was trying to use maven by command line and then this error message appeared.
I initially checked the java version with the following command
java -version
As it is was not on the required java version,I changed the java version by using following command
sudo update-alternatives --config java
This command gave me options to choose the required java version.
After proper selection of java I could perform the following command
mvn clean install -DskipTests
and the build was successful.Hence solved this issue
This worked for me.
mvn clean
mvn clean install
I want to study the java spring portion of the Jbehave-tutorial project at https://github.com/jbehave/jbehave-tutorial.
The README.MD states the REQUIREMENTS for building at the bottom:
Building the tutorial has been tested with Maven 3.0.5-3.2.1 and JDK 1.6-1.7. Newer versions of Maven and JDK should work but could also present issues.If you find any, please report them via JIRA
On my computer My Computer I am running Maven Version: 3.3.3 and STS Version: 3.6.4 for 64-bit Windows 7.
I really don't want to make an Atlassian account in order to resolve this issue if I can resolve it on StackOverflow.
So these are the steps I took to build JBehave-tutorial on my machine:
git clone https://github.com/jbehave/jbehave-tutorial.git
mvn clean install -Pstable # Issued in the main parent folder 'jbehave-tutorial'
Imported into Spring Tool Suite (STS) as an existing maven project.
Received the following errors in STS:
This lead me to believe that maven did not correctly download and build those dependencies so I looked into the .m2\repository\org\jbehave folder and this is what I seen.
Did anybody else get this to work?
What workarounds are there?
What correct maven dependencies to specify for JBehave tutorial project in pom.xml(s)?
I'm not immediately clear on your specific situation but here are dependencies required to use JBehave without Spring. (example pom below - you'll only need gherkin if your user scenarios are in gherkin).
https://stackoverflow.com/questions/30685909/jbehave-dependencies-not-available-in-central-maven-repo
I'm also going to hazard a guess that you're going to need the below at the appropriate version.
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-spring</artifactId>
<version>4.0.3</version>
</dependency>
Maven cannot find "SNAPSHOT" dependencies.
You need to google "Maven + dependency name without specified version" and check what is the latest version of them and make appropriate changes in pom file.
For example I have jbehave-web-runner version 3.6-beta-2 NOT 3.6-SNAPSHOT.
We use maven-release-plugin to release our maven components to repository(ies). However, some of these components use ranges on some of our dependencies. We want this because some of the dependencies are released often (Snapshots are not an option)
When we use release plugin the ranges are checked into scm and deployed to our maven repo. This doesn't make any sense since unresolved pom files in the maven repository could (and will) ensure that other build change for one build to another.
We tried using release:prepare-with-pom, but the just makes a new pom file that is committed to scm (release-pom.xml). The original pom with ranges is still deployed to the repo.
As another snag we would like to keep the ranges for the next development release. So our head/trunk should not b resolved.
I have this feeling that we are going about this the wrong way.
Can anyone please help us to solve our problem? If there are other ways to do this we would appreciate your suggestions.
I have stumbled upon two known maven release plugin bugs. Please see the following bug reports:
MRELEASE-618
MRELEASE-727
These are scheduled to be release in version 2.2.3 or 2.3 of maven-release-plugin
Edit as response to posted comments:
I agree that it is not obvious why these bugs solves my problem. I'll try to elaborate.
To get the release plugin to use the resolved pom file and deploy it you need to first use release:prepare-with-pom and then release:perform. If you want perform to deploy the resolved pom file you need to set the pomFileName in config to release-pom.xml. If not it deployes the unresolved pom.xml. Deployed pom files with ranges is not a good idea. This is why the 618 is needed.
The 727 is needed because the release-pom.xml is only checked in on the tag. When doing a release:perform your tag is checked out in the target directory. Because og the bug the plugin is looking for the release-pom.xml in the module root directory and comes up empty. This could also possibly go wrong without the pomFileName config, but less likely.
Ranges is generally a bad idea in Maven because it is buggy and because Maven does not by default deploy the resolved pom files. If Maven always deployed resolved pom files ranges would be a good idea.
I am trying to build the openNMS in eclipse helios using maven. After importing the source using "import existing maven project" i get the around 10k errors. Also i have some error in pom.xml itself, i thought fixing it could reduce the no of errors. The error in pom.xml is
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
Iam referring to http://www.opennms.org/wiki/Eclipse_and_OpenNMS for building the openNMS
Iam using maven available at http://www.eclipse.org/m2e/download/
It would help if you told us which versions of Eclipse & m2eclipse you are using, and which version of OpenNMS you are trying to build.
If all else fails, you should be able to run the Maven build from the command line. In my experience, command line builds are always more reliable and predictable.
Also make sure that you are using the instructions that match the version of OpenNMS you are trying to build.
I have run the command mvn eclipse:eclipse from cmd line which downloaded the libraries in repository then i tried to import the same source directory into eclipse only to find 10k errors
That's not what I meant.
Get out of eclipse.
Get a command prompt.
Create a new directory somewhere the is not in your eclipse workspace.
Checkout the source code.
From the command prompt run "mvn install".
And you haven't answered the questions I asked above. If you don't want to answer, fine ... but don't expect us to be able to help you.
... and i get the error as Build Failure [INFO] There are test failures.
What has happened is that the unit tests have failed, presumably because something needs to be set up to enable testing. (Perhaps, the tests are trying to talk to a database?)
There are two solutions:
Find out what is causing the tests to fail, and fix it. The surefire reports may give you some clues, and there may be some developer documentation on the test setup.
Turn off the tests by adding -Dmaven.test.skip=true to the mvn command line; see this page.
It would also be a good idea to read the Maven documentation if you haven't done so already.
You cannot combine eclipse:eclipse with the m2eclipse support. You cannot use m2eclipse with a project that uses the old resource plugin.
If you want to use eclipse:eclipse, you must use NOT use the 'maven' import from eclipse. Use just 'import existing project'. If you want to use m2eclipse, don't use eclipse:eclipse.
I had this issue with the PDFBox source, with the parent pom for that project. I put this in the pdfbox/pom.xml (just to get it to compile in eclipse at lease, which is the only thing I wanted):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<!-- had a process goal here that i removed because it was not compatible -->
</executions>
</plugin>
I have a straightforward maven2 java project (JMS relaying system). After we released the first version, we found that we spent more time configuring maven than actually coding.
For the next release we wanted to clean up the build process and someone suggested migrating to builder. So I was tasked with doing just that.
I setup buildr (1.3.4) according to the documentation on their website. And then from the root of the project I typed the buildr command and then informed buildr to create the build file based upon my pom.xml. That processed fine and compiled all the code. All was gravy until buildr started running the tests. Here is the ouput:
Test framework error: taskdef class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found
Obviously the class specified isn't in my classpath. However, the buildr documentation says that all the required items needed for basic testing are included. Their documentation doesn't say that they need any specific libraries for ant or a version of ant. Although I do have ant 1.7.0 installed (not included in my classpath however).
Has anyone seen this before?
Update
I located the infamous ant-optional jar on the maven repository. Including that in my test.with options did not resolve the issue.
Running the buildr command with --trace gives this extra information...
Tests failed!
/pathtoruby/buildr-1.3.4/lib/buildr/core/test.rb:455:in `run_tests'
/pathtoruby/buildr-1.3.4/lib/buildr/core/test.rb:199:in `initialize'
Found the issue... Apparently there is an ant-junit.jar that is needed but for whatever reason in my local repository it was owned by root and not my local user account (OSX system). So it wasn't accessible to buildr. I deleted the items from my local repository and reran buildr (it downloaded the needed items).
Update
Also this caused a few other issues. It seems that a few other items in my local repository had strange permissions. I ended up just archiving my repository and letting maven reconstruct it. This resolved all my issues. I now have a nice build file that is 25 lines of code compared to my previous pom.xml file that was over 100 lines.
You get that error because JUnitTask isn't on the classpath. I'm not very familiar with Buildr so can't say if it is required for you to specify the JUnit jars or not, but if Buildr uses the system classpath, try adding JUnit to it and see what happens.
Once you've confirmed your builds will run with JUnit hacked in to the classpath, you can then try varying your configuration until it runs as you expected, or leave it as is.
Can you post the reference to the relevant part of the documentation? I didn't see anything (in my very brief reading of the site) that says required items are included.
Is it possible that you've not downloaded all the gems? If you run "gem update --system" to update Ruby, then "gem update buildr" you can ensure that the required dependencies have all been installed.