Java+Maven builds on Jenkins but not on local machine - java

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).

Related

maven-enforcer-plugin False Positive RequireJavaVersion

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.

Quickfixj setting up sources for development - Could not find artifact org.quickfixj:quickfixj-codegenerator

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.

Cannot find org.wildfly.swarm.bootstrap.Main when launching fatjar built by wildfly-swarm-plugin:1.0.0.Alpha1

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...

Emacs Java Malabar Mode

I was using JDEE for my java projects in Emacs. JDEE does not work well for maven. Recently I came across Malabar Mode which has better support for Maven based Java projects in Emacs.
I managed to install malbar-mode using melpa in M-x list-packages. But when I'm getting error message on mvn package for my simple app https://github.com/vijayendra/JavaSrc/tree/master/my-app
Projects.get('/home/egnyte/src/my-app/pom.xml', []).run(['package'], [], [:])
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.081s
[INFO] Finished at: Sat Dec 06 23:55:22 PST 2014
[INFO] Final Memory: 20M/48M
[INFO] ------------------------------------------------------------------------
[ERROR] Execution error
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for or\
g.apache.maven.plugins:maven-resources-plugin:jar:2.5
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:129)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
My emacs version is as follows:
emacs -version
GNU Emacs 24.3.1
Copyright (C) 2013 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
My .emacs file is as follows:
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
;; unstable packages
;; (add-to-list 'package-archives
;; '("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(require 'cedet)
(require 'semantic)
(load "semantic/loaddefs.el")
(semantic-mode 1)
(setq malabar-groovy-lib-dir "~/.m2/repository/com/software-ninja/malabar/1.5.10")
(require 'malabar-mode)
(add-to-list 'auto-mode-alist '("\\.java\\'" . malabar-mode))
My maven version is as follows:
mvn -version
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T13:58:10-07:00)
Maven home: /home/egnyte/lib/apache-maven-3.2.3
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.0-29-generic", arch: "amd64", family: "unix"
How can I get malabar mode to work?
There are two answers.
First, malabar-mode is stuck at maven 3.0.4 so try that version. Also do not set the lib dir. It should be set automatically.
Second, in order to get around the maven version I am rewriting malabar-mode from scratch. Follow the instructions at https://github.com/m0smith/malabar-mode/blob/develop/doc/2.0/INSTALL.md. This version should work for all versions of maven after 3.0.4. It is a work in progress and not all the features are there yet.
If you have problems or suggestions create an issue in the GitHub repo as now is a good time to get your wishes known
EDIT: 2.0 of malabar has been released to MELPA. To install now:
```
(load-file "~/projects/cedet/cedet-devel-load.el")
(add-hook 'after-init-hook (lambda ()
(message "activate-malabar-mode")
(activate-malabar-mode)))
(add-hook 'malabar-java-mode-hook 'flycheck-mode)
(add-hook 'malabar-groovy-mode-hook 'flycheck-mode)
```

Does this Maven plugin really have an invalid descriptor?

COMMAND:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.beardedgeeks -DarchetypeArtifactId
=gae-eclipse-maven-archetype -DarchetypeVersion=1.1.2 -DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/release
s
OUTPUT:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Internal error in the plugin manager getting plugin 'org.apache.maven.plugins:maven-archetype-plugin': Plugin 'org.apache.maven
.plugins:maven-archetype-plugin:2.0-alpha-4' has an invalid descriptor:
1) Plugin's descriptor contains the wrong group ID: net.kindleit
2) Plugin's descriptor contains the wrong artifact ID: maven-gae-plugin
3) Plugin's descriptor contains the wrong version: 0.5.9
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 09 20:48:35 CEST 2010
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
I have a hard time believing this Maven plugin has an invalid descriptor since other people seem to be using it with no problem. Am I doing something wrong?
Can't reproduce your problem, the following command works fine for me (copied & pasted from GAE + Eclipse + Maven Archetype):
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate \
-DarchetypeGroupId=org.beardedgeeks \
-DarchetypeArtifactId=gae-eclipse-maven-archetype \
-DarchetypeVersion=1.1.2 \
-DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/releases
Tested with Maven 2.2.1:
$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_20
Java home: /usr/lib/jvm/java-6-sun-1.6.0.20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-22-generic" arch: "i386" Family: "unix"
I often experience problems with crappy metadata in my local repository. This kind of error usually vanishes after I do
rm -Rf my/home/dir/.m2/repository/net/kendleit/maven-gae-plugin
but actually the reason why it works with Pascal is that Pascal uses this url http://beardedgeeks.googlecode.com/svn/repository/releases whereas you use this url http://beardedgeeks.googlecode.com/svn/repository/release (an s is missing, hence there's a 404)
do the rm as mentioned above and then run again with the correct url
EDIT: sorry there is actually a trailing s I didn't see. I take everything back, but still: try to delete the metadata in your local repo
Reason:
the GAV (groupid, artifactid, version) in Nexus (consequently in local repository and in the pom.xml) is not the same as the one in the jar file in \META-INF\maven\plugin.xml
This usually happens when you upload manually the plugin artifact in your own Nexus (or any other maven enterprise repository)
Solution:
download the jar, see what are the GAV values in plugin.xml
upload the jar on Nexus, passing as GAV the information from the plugin.xml
Update the pom.xml accordingly
Make sure to remove from Nexus the old inconsistent artifact.

Categories

Resources