I'm new to a project and the project is using the maven-enforcer-plugin.
The plugin (version 3.0.0) is configured to require Java 11
<requireJavaVersion>
<version>11</version>
</requireJavaVersion>
I also have jdk 11 on my path
$ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)
However, when I run mvn clean verify I get a failure saying that I'm on Java 8 when Java 11 is required
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-versions) # checkstyle ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.8.0-261 is not in the allowed range 11.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.231 s
[INFO] Finished at: 2022-04-21T18:04:07-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce (enforce-versions) on project checkstyle: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
-> [Help 1]
Why would I be getting this error?
In my case, my issue was that my user JAVA_PATH variable was configured to Java 8, but my system JAVA_PATH was configured for 11. It looks like maven uses the user's JAVA_PATH.
Related
I can't import successfully the QuickFIX/J project into any of my IDEs, I've tried with Eclipse, VS Code and IntelliJ.
Following the QuickFIX/J project instructions, first I build the project with:
$ mvn clean package -Dmaven.javadoc.skip=true -DskipTests -PskipBundlePlugin
Everything goes well in the build:
[INFO] Building zip: /home/helesto/kdi/github/quickfixj/quickfixj-distribution/target/org.quickfixj-2.2.1-SNAPSHOT-bin.zip
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for QuickFIX/J Parent 2.2.1-SNAPSHOT:
[INFO]
[INFO] QuickFIX/J Parent .................................. SUCCESS [ 4.654 s]
[INFO] QuickFIX/J Code Generator Maven Plugin ............. SUCCESS [ 28.844 s]
[INFO] QuickFIX/J Dictionary Generator .................... SUCCESS [ 1.178 s]
[INFO] QuickFIX/J Core engine ............................. SUCCESS [06:51 min]
[INFO] QuickFIX/J Message classes for various FIX specs ... SUCCESS [ 0.003 s]
[INFO] QuickFIX/J Message classes for FIX 4.0 ............. SUCCESS [ 1.028 s]
[INFO] QuickFIX/J Message classes for FIX 4.1 ............. SUCCESS [ 0.835 s]
[INFO] QuickFIX/J Message classes for FIX 4.2 ............. SUCCESS [ 0.874 s]
[INFO] QuickFIX/J Message classes for FIX 4.3 ............. SUCCESS [ 0.839 s]
[INFO] QuickFIX/J Message classes for FIX 4.4 ............. SUCCESS [ 1.082 s]
[INFO] QuickFIX/J Message classes for FIX 5.0 ............. SUCCESS [ 1.349 s]
[INFO] QuickFIX/J Message classes for FIX 5.0 SP1 ......... SUCCESS [ 1.283 s]
[INFO] QuickFIX/J Message classes for FIX 5.0 SP2 ......... SUCCESS [ 1.215 s]
[INFO] QuickFIX/J Message classes for FIXT 1.1 ............ SUCCESS [ 0.710 s]
[INFO] QuickFIX/J Message classes for all FIX specs ....... SUCCESS [ 2.294 s]
[INFO] QuickFIX/J Examples ................................ SUCCESS [ 0.004 s]
[INFO] QuickFIX/J Examples - Executor ..................... SUCCESS [ 7.030 s]
[INFO] QuickFIX/J Examples - Order Match .................. SUCCESS [ 4.830 s]
[INFO] QuickFIX/J Examples - Banzai ....................... SUCCESS [ 5.036 s]
[INFO] QuickFIX/J All runtime modules ..................... SUCCESS [ 18.797 s]
[INFO] QuickFIX/J Distribution ............................ SUCCESS [ 16.725 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:31 min
[INFO] Finished at: 2021-01-15T19:11:18-03:00
[INFO] ------------------------------------------------------------------------
Then I try to import it into the IDEs and something goes wrong with the quickfixj-codegenerator.
I've tried some things that I've found on the internet, but nothing solve my problem.
I'll be very happy if someone could help me :)
My machine
Maven
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /kdi/maven
Java version: 11.0.9.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-36-generic", arch: "amd64", family: "unix"
Java
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
javac 11.0.9.1
OS
Linux machine 5.8.0-36-generic #40~20.04.1-Ubuntu SMP Wed Jan 6 10:15:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
QuickFIX/J build instructions
At https://www.quickfixj.org/usermanual/2.1.0/installation.html#dependencies I've found:
IDE support:
There are Eclipse and Netbeans project definition files in the top-level directory of the checked out directory. When the project is first created, it will not have the generated message classes and compile errors will occur! Best is to compile once on the command line before importing the project into the IDE.
I've searched the project documentation and I didn't find nothing about this issue.
Eclipse - Error
Version: 2020-12 (4.18.0)
Reports the following error when I import the project:
No marketplace entries found to handle maven-plugin-plugin:3.2:descriptor in Eclipse. Please see Help for more information.
No marketplace entries found to handle Execution default-descriptor, in /quickfixj-codegenerator/pom.xml in Eclipse. Please see Help for more information
After importing, the /quickfixj-codegenerator/pom.xml says that:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor (execution: default-descriptor, phase: process-classes)
VS Code - Error
Version 1.52.1
Error:
Could not find artifact org.quickfixj:quickfixj-codegenerator:jar:2.2.1-SNAPSHOT
IntelliJ - Error
Version Community 2020.3.2
Error:
Cannot resolve plugin org.quickfixj:quickfixj-codegenerator:2.2.1-SNAPSHOT
Cannot resolve plugin org.apache.maven.plugins:maven-install-plugin:<unknown>
QuickFIX/J email support - same issue as mine
The same issue was reported on the email of support discussion of Quickfixj:
https://sourceforge.net/p/quickfixj/mailman/message/36623115/
On the email thread, I didn't find the answer to this problem.
The problem was reported on 2019, March. The only difference for me is that the Quick/FIXJ is now in a newer version.
Quoting the same problem of the email:
I'm trying to create a development environment for quickfixj on eclipse. I
cloned the repository, downloaded the sources, and ran the command:
mvn clean package -Dmaven.javadoc.skip=true -DskipTests -PskipBundlePlugin
just as suggested on the website. This part worked without any errors.
Afterwards, I try to import the projects in eclipse. The projects are
identified as maven projects and added to the workspace, but when
compiling, after the import, it shows the error:
Could not find artifact
org.quickfixj:quickfixj-codegenerator:jar:2.2.0-SNAPSHOT
Which does not allow quickfixj-core to build, which in turn does not allow
any other projects to compile, since they all depend on the core project.
I have tried a suggestion I found on the net, to run
mvn eclipse:eclipse to help build the eclipse projects but by the time it
reaches the core engine project, it throws the same error:
[ERROR] Plugin org.quickfixj:quickfixj-codegenerator:2.2.0-SNAPSHOT or one
of its dependencies could not be resolved: Could not find artifact
org.quickfixj:quickfixj-codegenerator:jar:2.2.0-SNAPSHOT -> [Help 1]
I was able to successfully import the project into IntelliJ and Netbeans using the help of #ChristophJohn.
First, run:
mvn clean install -Dmaven.javadoc.skip=true -DskipTests -PskipBundlePlugin
And then just import it to IntelliJ or Netbeans.
I wasn't able to import it to Eclipse or VS Code. But, as this worked with IntelliJ and Netbeans, for me it is enough.
I have a strange problem. My build is working on Jenkins but not locally. It used to work locally but stopped for some reason.
I have no uncommitted changes. The code on Jenkins is in sync with my master branch(using Git).
I have deleted all uncommitted files from my local machines project.
Mvn -version on local machine:
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
Maven home: /Users/andersvincentlund/Downloads/apache-maven-3.5.2
Java version: 9.0.4, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
Default locale: en_SE, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
Tool configuration on Jenkins machine:
jdk-9.0.1
apache-maven-3.5.2
Compiler plugin in Maven in the code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Build result on Jenkins:
[INFO] Reactor Summary:
[INFO]
[INFO] RootProject ..................................... SUCCESS [ 1.781 s]
[INFO] ProjectA ........................................ SUCCESS [ 15.344 s]
[INFO] ProjectB ............................................ SUCCESS [ 35.063 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Build result from local machine:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] RootProject ..................................... SUCCESS [ 0.350 s]
[INFO] ProjectA ........................................ SUCCESS [ 1.285 s]
[INFO] ProjectB ............................................ FAILURE [ 1.402 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Failures in ProjectB are referencing packages in Project A. All look like this:
[ERROR] /somePath1/src/main/java/somePath2/SomeFile.java:[10,38] error: package some.package.in.projectA does not exist
I know my Maven and Java aren't exactly the same version on the different machines. The local one is a Mac running Sierra. The remote one is Windows Server 2012 R2. Since I am using the maven compile plugin to set the version to Java 7 it shouldn't be a problem right? I don't get this. Normally the issue is that it is working locally but not on Jenkins. This is the other way around. Help would be greatly appreciated. Starting to feel really stupid over here.
EDIT:
Tried on another Mac. Same result as with my Mac, failure. Created a VM with Windows and tried again, same result as with the server. Success. Seems to be a problem isolated to Mac. It has worked on Mac before so I am considering if an update has broken something.
I a compile action works on Windows but not on OSX/Linux the most common failure is a file with wrong uppercase or lowercase character in the file name (or directory name).
As Windows works case insensitive it is able to find and access the file.
OSX and Linux are working case sensitive and therefore are not able to acces the file.
Check the directory names of the package some.package.in.projectA
and the filename of the Java files that they exactly match the package respectively class name(s).
I've checked out https://github.com/arun-gupta/wildfly-samples/tree/master/swarm by Arun Gupta, but when trying to launch the built jar I get Error: Could not find or load main class org.wildfly.swarm.bootstrap.Main.
\wildfly-samples-master\swarm>mvn clean install
[INFO] --- wildfly-swarm-plugin:1.0.0.Alpha1:create (default) # swarm ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # swarm ---
[INFO] Installing \wildfly-samples-master\swarm\target\swarm-1.0-SNAPSHOT.war to \.m2\repository\org\wildfly\samples\swarm\swarm\1.0-SNAPSHOT\swarm-1.0-SNAPSHOT.war
[INFO] Installing \wildfly-samples-master\swarm\pom.xml to \.m2\repository\org\wildfly\samples\swarm\swarm\1.0-SNAPSHOT\swarm-1.0-SNAPSHOT.pom
[INFO] Installing \wildfly-samples-master\swarm\target\swarm-1.0-SNAPSHOT-swarm.jar to \.m2\repository\org\wildfly\samples\swarm\swarm\1.0-SNAPSHOT\swarm-1.0-SNAPSHOT-swarm.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.115 s
[INFO] Finished at: 2015-05-26T21:06:59+01:00
[INFO] Final Memory: 49M/313M
[INFO] ------------------------------------------------------------------------
\wildfly-samples-master\swarm>java -jar target/swarm-1.0-SNAPSHOT-swarm.jar
Error: Could not find or load main class org.wildfly.swarm.bootstrap.Main
\wildfly-samples-master\swarm>mvn --version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)
Maven home: C:\tools\apache-maven-3.2.1
Java version: 1.7.0_21
Java home: C:\Progra~1\Java\jdk1.7.0_21\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
I do not understand what might be the problem here.
Can someone please advise?
EDIT: I have tried building my own example first but I'm getting the same problem. Referring to an existing example which fails for me was just easier.
This was a known issue in Alpha1
that was already fixed https://github.com/wildfly-swarm/wildfly-swarm/commit/761cdf1848a8720614b20a2272983bcd4e5f3c60
Best to build it from sources until Alpha2 release is done.
These are the official examples:
https://github.com/wildfly-swarm/wildfly-swarm-examples
Alpha4 version (source) has:
EJB support.
More bug fixes.
Static content support. (js,html,css, etc...)
And many others improvements...
I trying to figure out what is happening with my maven. I have switch to windows 8 last days and found problem with building apps with maven (please see failure message at the bottom):
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.400s
[INFO] Finished at: Sat Apr 13 18:36:56 CEST 2013
[INFO] Final Memory: 18M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Example: Could not resolve dep
endencies for project
(Here are lots of libs)
Could not transfer artifact com.sun.xml.bind:jaxb-impl:pom:2.2.4-1 from/to central (
http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org
refused: connect: Address is invalid on local machine, or port is not valid on
remote machine -> [Help 1]
When switched to java 6, eveything is working fine. I have even disabled windows firewall, without any success though. Maybe someone has faced with that problem?
Here is my environment:
Windows 8 x64
JDK 7u17 (check on both, x86 and x64)
Maven 3.0.5
Well the answer look is so simple that I'm embarrassed to give but... . As I have written above I have disabled firewall / antyvirus but without any effect. However I don't add java as a exception to my antyvirus, which is as it turns out, scanning my apps and don't allow some to access event if it's disabled... . That's wierd but adding an exception in AV helped. Sorry for bother....
I am fairly new to UNIX and i am trying to use CraftBukkit to run my Minecraft Server.
This is what I did:
$ git clone git://github.com/Bukkit/CraftBukkit.git
$ cd CraftBukkit
$ mvn clean install
This is the error I get...
sam#qntm:~/CraftBukkit$ mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building CraftBukkit
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory /home/sam/CraftBukkit/target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 133 source files to /home/sam/CraftBukkit/target/classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Unable to locate the Javac Compiler in:
/usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
Unable to locate the Javac Compiler in:
/usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Feb 08 17:42:57 MSK 2011
[INFO] Final Memory: 12M/151M
[INFO] ------------------------------------------------------------------------
Apologies if there is a really simple and obvious solution.
ensure that your JAVA-HOME variable is set to proper path. Here is described how to set it properly http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/