Jenkins-Maven-Tomcat-Nexus: compilation failed - java

I implemented a java project with eclipse environment, i use maven to manage dependencies and inject some jars files in TOMCAT_HOME/lib.
When compile project in jenkins, compilation failed because missing of jars (which in tomcat/lib).
How can I solve this please?

Related

Strange maven compilation error while building project

Strange maven compilation error while building project.
Hi,
I'm facing a trivial but rather a very strange issue with respect to maven project build.
I'm using Intellij as the IDE.
I've a maven project A which has two maven modules B and C
A
|
|
|--B
|
|--C
The module C is a test module which has a dependency on module B.
Now, when I build the entire project using mvn clean install, it complains of "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin error: cannot find symbol
However, there is no compilation error shown on intellij.
Additionally, to my surprise, my test runs without any issue.
I've tried to execute different intellij options viz. (re-import/sync/invalid caches and restart), but in vain.
I've also tried to play around with the version of maven-compiler-plugin.
Can someone please help me what can be the reason of the failure? Thanks.
the issue was occuring due to spring boot maven plugin's repackage goal.
The repackage goal replaces the original jar with the repackaged one.
The reason for the compilation issue is that application classes are packaged in BOOT-INF/classes so that's why the dependent module couldn't load a repackaged jar's classes.
More info here :
https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/repackage-classifier.html

maven project build shows Compilation failure

I am creating a web application using spring mvc with eclipse as my IDE and every time I build my project I keep getting getting the following :- Compilation failure: Compilation failure:
[ERROR] /C:/Users/dev1/project/GeoVision/src/main/java/com/mmi/controllers/GeoJsonToShp.java diamond operator is not supported in -source 1.5
I have changed the java build path and set it to latest JRE and even then the error won't go.
Also, I am able to run the project on server?
Please suggest what is it that I have to change to successfully build my project?
You need to configure the compile level in IDE settings
Or configure the maven file (probably this rather than eclipse)

Picketlink Source Compile Error

I am trying to compile picketlink from source but it keeps failing with the same error when running either mvn install or mvn package.
It always fails on 'PicketLink Identity Management API' with the error
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project picketlink-idm-api: Compilation failure
error: java.lang.NullPointerException
I have tried with versions 2.5.0, 2.5.1, 2.5.2, 2.6.0, and 2.6.1.
Whats wrong and how can I fix this?
Thanks
You can try to compile using a web archive (war) package? It also might help to start a new project with just the one dependency. It might help you narrow down the problem.

springframework source in Idea Intellij

I'm having hard time to setup springframework code in Intellij.
I git-cloned springframework project from github, and ran ant task to get all the libraries into ivy-cache directory.
I found "spring-framework.ipr" file for intellij project, and opened it.
Unfortunately, some of the libraries are not correctly mapped to the jar files or missing. So I cannot compile the codebase in IDE.
I also tried importing as eclipse project into intellij. Jar file reference seems ok.
But there are compilation errors in OXM module. Some test classes have reference to auto generated classes such as "~.samples.flight.FlightDocument", "~.jaxb.test.FlightType", and they don't exist(ant test goal generates them in target dir).
It seems same problem happens in STS.
I referenced this blog post:
http://blog.springsource.org/2009/03/03/building-spring-3/
Any good idea to setup spring code in intellij?
I use intellij v11.
git branch: 3.1.x
git commit: e8fc90ce3e4554f14eaa86ce05591249d3fe62fa
Compilation error example:
.../org.springframework.oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller Tests.java
Error:(29,42) package org.springframework.samples.flight does not exist
Error:(30,42) package org.springframework.samples.flight does not exist
Error:(44,9) cannot find symbol class FlightsDocument
Error:(44,58) package FlightsDocument does not exist
....
Thanks,
problem solved.
"spring-framework.ipr" is the one for intellij.
lesson learned:
simply wrong version of junit was referenced in spring-framework.ipr file.
when ant build failed middle of the test, subsequent module won't be built. so, required libraries won't be downloaded into ivy-cache/repository.
"ant jar" goal will not download test related libraries since the goal doesn't run tests
After all the tests passed and manually fixed junit reference, intellij finally has no errors.

In maven multi-module project, how to package a single child-project?

I'm working on a multimodule maven project. Some time ago, the project was partitioned into subprojects:
"Common" JAR project
"User" WAR project, depending on Common
etc.
It's the same project as described here, in this question.
When I invoke mvn package at superproject level, command succeeds and resulting war can be deployed. But if I try to invoke mvn package at subproject level, command fails.
[ERROR] Failed to execute goal on project User: Could not resolve
dependencies for project xxx.xxx:User:war:0.0.1-SNAPSHOT: Failed
to collect dependencies for [xxx.xxx:Common:jar:0.0.1-SNAPSHOT (compile), ...
Apparently maven is trying to download my own project (Common) from remote repo...
Downloading: http://repository.jboss.org/maven2/xxx/xxx/Common/0.0.1-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/glassfish/xxx/xxx/Common/0.0.1-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata xxx.xxx:Common:0.0.1-SNAPSHOT/maven-metadata.xml from/to jboss (http:/
/repository.jboss.org/maven2): Access denied to: http://repository.jboss.org/maven2/xxx/xxx/common/0.0.1-SNA
PSHOT/maven-metadata.xml
What could possibly be wrong in my config?
When you run mvn package from superproject, it creates the artifacts in the respective target folder, but does not install them in your local repository.
So, when you run mvn package on a subproject, which has a dependency on a sibling module, it looks for the dependency in your local repository, does not find it and thus attempts to download it from the various repositories configured.
Once you successfully run an mvn install from superproject, an mvn package on the subproject should work.
You have a (JBoss) repository entry either in your pom.xml or settings.xml.
To access this repository it is required to be authenticated. If you call the path with your browser, you get also "403 Forbidden". You have to add a public repository of Jboss. (http://repository.jboss.org/)
I have spent a lot of time to find out this sort of 'ERROR', thanks to Raghuram, I was stupid when trying to find the solution but there was actually no error, just because I did mvn install in a submodule which depends on dependencies of other modules, It should work fine when i run mvn install/package on parent scope.

Categories