Maven + Delombok issue when compiling in Eclipse - java

I have a maven project in Eclipse that uses lombok/delombok.
When I build, from Eclipse, using a maven script (e.g. mvn clean package), everything works fine.
However, when I run directly from Eclipse (say with a clean/build of my project), I have a classpath issue concerning a class that should be present in the tools.jar from the JDK. I have tried adding the tools.jar directly in my project build path, without any success.
[Edit]
The stack trace is:
03/07/11 23:39:44 CEST: Maven Builder: FULL_BUILD
03/07/11 23:39:44 CEST: [WARN] The POM for com.google.code.gwt-log:gwt-log:jar:3.1.2 is missing, no dependency information available
03/07/11 23:39:44 CEST: Build errors for fiveorbs; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok (default) on project fiveorbs: Execution default of goal org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok failed: A required class was missing while executing org.projectlombok:maven-lombok-plugin:0.9.3.1:delombok: com/sun/tools/javac/util/Context
-----------------------------------------------------
realm = plugin>org.projectlombok:maven-lombok-plugin:0.9.3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/maven-lombok- plugin/0.9.3.1/maven-lombok-plugin-0.9.3.1.jar
urls[1] = file:/C:/Program%20Files/Java/jdk1.6.0_26/jre/../lib/tools.jar
urls[2] = file:/C:/Users/Daedin/.m2/repository/org/projectlombok/lombok/0.9.3/lombok-0.9.3.jar
urls[3] = file:/C:/Users/Daedin/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
[/Edit]
My configuration is as follows:
Eclipse 3.6 Helios
Maven 2.3
JDK 1.6
Lombok 0.9.3
Delombok maven plugin 0.9.3.1
The part of the pom.xml that contains the declaration of the delombok plugin is as follows:
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>maven-lombok-plugin</artifactId>
<version>0.9.3.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
I apologize if this question seems trivial, but I have been looking for an answer for a couple of hours, and I'm starting to get stuck.
Thanks in advance for any hint you may be able to provide - and please let me know if I have omitted any useful information.

You need to make sure Eclipse is launched using a JDK (not a JRE). To be sure, set the path to the executable in eclipse.ini
on *x systems (probably includind MacOS):
-vm /path/to/jdk/bin/javaw
on Win*:
-vm
C:\path to jdk\bin\javaw.exe
(needs to be on separate lines, no quotes - see https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example )
To determine which JVM Eclipse launched under, you can use Help->About, Installation Details, Configuration. Then look for the -vm line. If you see multiple -vm lines, or the -vm line points at a JRE instead of a JDK, adjust eclipse.ini then relaunch Eclipse and do a Maven->Update on the project.

I think the problem has been solved in Lombok 0.10.0 or higher

I had a similar issue with delombok when compiling on a Linux VM, when the source was using a mounted Windows share. In my case the problem was solved by moving the repository to another location exclusively on the Linux VM, then recompiling.

Have you configured your Eclipse by executing lombok.jar?
Also Lombok requires javac 1.6 or higher

I had this issue yesterday afternoon. I am using Java 8, Eclipse oxygen, maven 3.5.2.
Solution:
The issue got resolved by removing the Lombok dependency from pom and by adding the Lombok jar in the build path by downloading it separately.
I also edited the eclipse.ini and added the following:
-javaagent:lombok.jar
I downloaded 1.16.18 version of Lombok jar.

Related

When try to mvn clean install -> an error package does not exist appear

I have been trying to do: mvn clean install on a project which depends on external jar, but got:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile (default-testCompile) on project automation-service: Compilation failure: Compilation failure:
[ERROR] /C:/Checkouts/Release-4.0/test-service-intelligence/service-automation-service/src/test/java/com/company/automation/steps/BasicsSteps.java:[16,53] package com.company.service.automation.databaseaccess does not exist
/C:/Checkouts/Release-4.0/test-service-intelligence/service-automation-service/src/test/java/com/company/automation/steps/BasicsSteps.java:[43,13] cannot find symbol
[ERROR] symbol: class IdentifierIndexRepository
and weirdly this was successfully executed on my colleagues MAC (although he is using completely different IDE, tools and stuff. For example he is using X-Code IDE, ZULU 8 JDK, Maven 3.5). Firstly I though it is a JDK problem and switch the JDK as the same as his: ZULU 8, then I tried his version of Apache Maven and downgraded from 3.6 to 3.5. And finally I switched from Intelij Idea to Eclipse out of desperation -> nothing helps me.
It seems that the missing package is from an external dependency jar which is supplied successfully - I can see it in the External libraries, also there is no signs for unresolved dependencies before trying to mvn clean install (mvn clean compile pass successfully)
the dependency in the POM is declared like that:
<dependency>
<groupId>com.company.da.fid.resolve</groupId>
<artifactId>automation-database-access</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
and maven-compiler-plugin like that:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
The dependency .jar file consists his owns dependencies in him.
Anyone have an idea or clue what possibly could happen to me ?
Thanks in advance.
From the error log it shows that you are missing the dependency com.company.... And it seems to me that it is a custom library you are using. If you have the source code, do clean install of the lib and then on the main project.
This may occur if you have a corrupt package(of the dependency) locally. To check this go to .m2 folder and verify that you have it, if so delete and try to run clean install again.

Adding local jars to Java projects with Java 10

I have used Maven with earlier versions of Java but now I am trying to get it to work with Java 10. I built a simple Hello world project, specifically:
package main;
public class Test {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
With a module-info class:
module maven.test {
exports main;
}
The pom associated with this project is:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
MavenTest
MavenTest
0.0.1-SNAPSHOT
MavenTest
src
maven-compiler-plugin
3.7.0
10
When I build the project, it build successfully. I then added a dependency from the Maven central repository:
org.jsoup
jsoup
1.7.3
This too builds successfully. I then add a locally installed jar.
<dependency>
<groupId>com.artificialmed</groupId>
<artifactId>DBconnectValueObjects</artifactId>
<version>1.0</version>
</dependency>
When I do this, I get a Build Failure with the following error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project MavenTest: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed. IllegalArgumentException -> [Help 1]
[ERROR]
I've not found anything that would help me resolve this error. When I rebuilt the project using full debugging logging, I saw no useful information. I know the local jar was installed in my repository correctly because when I include that jar in projects compiled in Java 7, the project builds successfully. So, I suspect this is some issue related to Java 10 and locally installed jars.
Does anyone know how to get around this issue?
Elliott
I think this might be related to this question.
Basically, I don't think your problem is related to the local jar - If you've installed it in your local maven repository ($USER_HOME/.m2) using the maven install plugin, it has a pom.xml and to maven shouldn't be distinguishable from any other maven dependency.
The only thing I see "wrong" is the version of the maven compiler plugin - the current version is 3.8.0, which I'm using with Java 11 without any issues so far.
Also, note that the mechanism to set the source and target java releases changed, as in the following snippet:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>10</release>
</configuration>
</plugin>
</plugins>
</build>

Eclipse - Maven dependency is being ignored

I have a problem with adding maven dependencies to eclipse.
What should be OK:
pom.xml already contains all the dependencies and compilation and running tests using maven finished with success
all the source folders were recognized by eclipse
eclipse has Maven plugin and project is managed as maven project (see figure below)
pom.xml has maven-compiler-plugin, so the eclipse should know it is a maven project
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Issue:
eclipse does not resolve dependencies defined in pom.xml (guava, juint and other libraries are in pom.xml but not in eclipse class path)
any right click > Maven > Update project has no any effect (see figure below)
I noticed that libraries does not contain any Maven Managed Dependencies - by adding as described below has no any effect
My attempt to add Maven Managed Dependencies to Eclipse manually
1) Add library
1)
This attempt has no any effect and "Java Library Path" remains the same even after this action.
2)
Command
mvn eclipse:eclipse
Fails with
[ERROR] Failed to execute goal on project pmml-model: Could not resolve dependencies for project org.jpmml:pmml-model:jar:1.3-SNAPSHOT: The following artifacts could not be resolved: org.jpmml:pmml-agent:jar:1.3-SNAPSHOT, org.jpmml:pmml-schema:jar:1.3-SNAPSHOT: Could not find artifact org.jpmml:pmml-agent:jar:1.3-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]
The jar does not exist in the desired version on the server your maven script is referencing. The most recent version is 1.2.9. The snapshot version is not present. You should reference
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-model</artifactId>
<version>1.2.9</version>
</dependency>
in your pom.xml.
The below jars are not present in your remote repo.
org.jpmml:pmml-agent:jar:1.3-SNAPSHOT,
org.jpmml:pmml-schema:jar:1.3-SNAPSHOT
Open the url https://oss.sonatype.org/content/repositories/snapshots in your browser to see the available snapshots/
Apparently, you are trying to set up a project that makes use of the JPMML-Evaluator library. In that case, you should only depend on the latest stable org.jpmml:pmml-evaluator dependency (which is version 1.2.13 at the moment). In other words, don't try to manage the associated org.jpmml:pmml-model, org.jpmml:pmml-schema dependencies manually.
You could base your work on the JPMML-Evaluator-Bootstrap project instead.

Intellij 13 Ultimate not able to find supported files

I'm using Intellij 13 Ultimate on Windows 7 enterprise. My maven pom includes the following:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration/>
</plugin>
</plugins>
</reporting>
I have settings.xml configured to access Nexus repositories within the firm for whom I am working.
Within intellij, the '2.9.1' displays in red and I see : Plugin "org.apache.maven.plugins:maven-javadoc-plugin:2.9.1" not found.
At the windows command line, though, I am able to download the artifact to the local repo using the same settings.xml file and the command:
C:\swdtools\apache-maven-3.1.1\bin>mvn org.apache.maven.plugins:maven-dependency
-plugin:2.1:get -DrepoUrl=https://dsnexus.uk.<HIDDEN>.<HIDDEN>:8081/nexus -Dartifact=org
.apache.maven.plugins:maven-javadoc-plugin:2.9.1
Intellij doesn't pick it up if I do 'reimport all maven projects'.How to fix or debug this further within intellij?
I have the same issue while including the report plugin "maven-jxr-plugin" with IDEA 13, but other plugins are work well.
The plugin could be found in Central Repo, but not in local.
One solution is to move the declaration from report section to build section, then the downloading will be triggered, and the reporting still works.
I changed config intellij's config dirs in 'idea.properties' and found the 'idea' log file. The dependency problem went away as soon as I changed config dirs, no explanation, except that i didn't realize intellij was throwing errors until I ran 'idea.bat' at the command line. So - 1/ run from command line 2/ look into idea log file for unexplained problems

Error in POM.xml

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>

Categories