I have a maven project using java 10 and I want to edit it in eclipse photon. It more or less works ok, but I do get the warning:
Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
Setting the java compiler --> JDK compliance level to 10 in the project properties in eclipse doesn't remove this warning.
Is this an issue with the maven-compiler-plugin? I am currently using version 3.7.0 configured like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
<release>10</release>
<encoding>UTF-8</encoding>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version> <!-- Use newer version of ASM -->
</dependency>
</dependencies>
</plugin>
Tips on how to configure a maven project using java 10 and eclipse photon would be greatly appreciated.
The issue seems to be with the JRE specified on the build path of your project. Right-click on the project and then go to Properties > Java Build Path > Libraries. There, edit the JRE System Library specified to JRE 10.
Actually, my problem was related to the version of Spring Tool Suite I was using. It turns out that I had upgraded my environment using the update site instead of downloading the new version. I was using Spring Tool Suite 4.7.3a instead of 4.8.0. Using 4.8.0 resolved the issue.
Related
We are using the Tomee Maven Plugin for starting a Tomcat server and running some webapps. We need to use a specific version of Java, which is installed on the local system. Yet the Plugin picks the wrong Java version for starting Tomcat. We then get illegal argument exceptions due to the wrong Java version being used. How can we configure the Tomee Maven plugin to use a specific Java version?
Looking at the documentation there does not seem to be anyway to specify Java Version.
However each version of Tomee supports specific versions of Java, for example Java8/11, etc.
You could select the version that is suitable for your JDK version, as well ensure that your pom.xml has source/target for the specific java version you want:
<properties>
<tomee.version>7.0.2</tomee.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
You could also ensure that your maven compiler plugin uses the appropriate JDK:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Our project uses ant tool to build maven project. We are using java 1.6 and 1.8 for different OS related release. The build works fine for java 1.8 and same is failing when using 1.6 because of versions-maven-plugin which maven downloading is latest and compiled in 1.7.
I tried copying org.codehaus.mojo version plugin of 2.4 in local repository but still maven looking to latest 2.7 version. Is there is way to specify version in ant java task
<java classname="org.codehaus.classworlds.Launcher" fork="true" dir="#{basedir}" resultproperty="#{resultproperty}" failonerror="true">
You can specify the version of versions-maven-plugin in a pluginManagement section, something like:
<pluginManagement>
<plugins>
<plugin>
<artifactId>versions-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</pluginManagement>
Refer to: Maven2: How to be sure Maven build is using a specific plugin version?
Here is the Maven documentation:
https://maven.apache.org/pom.html#plugin-management
I have a problem which I want to share and probably find your assistance.
Just today I reinstall my Dev environment and realized that can't build my project using maven (version 3.6.3, but I've tried older as well). The issue stack trace is next:
Execution process of goal org.bsc.maven:maven-processor-plugin:4.0-rc1:process failed:
Unable to load the mojo 'process' in the plugin 'org.bsc.maven:maven-processor-plugin:4.0-rc1' due to an API incompatibility:
org.codehaus.plexus.component.repository.exception.ComponentLookupException:
org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
The Java version is : Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre
I've spent some time to understand what is wrong and why on the local machine it works but on the new DEV machine - doesn't. I know that problem is that the dependency of maven plugin (maven-processor-plugin) is built by a newer version than I use for a project. But WHY Maven loads this release candidate version instead of stable 3.3.3?
Then I removed ~/.m2/repository/org/bsc/maven/maven-processor-plugin from my local machine and... yes, I reached the same issue as I have on my Dev machine. My local Maven version is 3.6.1
I assume that Maven starts using the latest version of that plugin and moves forward without backward compatibility. It sounds like a last Java 8 days in the Maven eco-system, but I won't believe in that.
BTW: MAVEN PROCESSOR PLUGIN ยป 4.0-rc1 was released (Apr 17, 2020), this explains why previously I didn't have such an issue.
If someone has a similar issue or can explain what's going on with Maven - I will be so thankful. Thank you all in advance, stay safe!
P.S. How the plugin configuration looks like in pom.xml
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>src/generated</outputDirectory>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<compilerArguments>-ApersistenceXml="src/main/resources/META-INF/persistence-data.xml"</compilerArguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</dependency>
</dependencies>
</plugin>
P.P.S. I'm not blocked by this, because I just used a Version tag and set the latest stable version of the plugin 3.3.3. But I'm still curious why such conflict happens. And, again, I will be so happy for any ideas and comments.
I am using job-dsl plugin to automate jenkins jobs creation. Below is my maven configuration.
<java.version>1.8</java.version>
<groovy.version>2.4.4</groovy.version>
<dsl.version>1.37</dsl.version>
<groovy.eclipse.compiler.version>2.9.101</groovy.eclipse.compiler.version>
<groovy.eclipse.batch.version>2.3.7-01</groovy.eclipse.batch.version>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>${groovy.eclipse.compiler.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>${groovy.eclipse.batch.version}</version>
</dependency>
</dependencies>
</plugin>
I am using jdk8 & groovy-all 2.4.4 ,groovy-eclipse-compiler & an uber jar is generated using shade plugin. To run my scripts, I added additional classpath (under process job-dsl/advanced-settings) as target/my-uber.jar.
When I run my tests locally everything works well but on Jenkins am getting following errors
java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for com.salesforce.dva.pipeline.generator.model.PkgType do not match. Expected -1 but got 2
at groovy.lang.MetaClassImpl.selectConstructorAndTransformArguments(MetaClassImpl.java:1413)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.selectConstructorAndTransformArguments(ScriptBytecodeAdapter.java:234)
I tried changing groovy versions (to older) & setting jdk 7 & 6 but all of them resulted in the same error.
How can I fix this issue ?
Jenkins uses Groovy 1.8.x, so the Job DSL plugin also uses Groovy 1.8.x. Currently it's 1.8.9. The update to Groovy 2.x is still pending, See JENKINS-21249. It's recommended to use Groovy 1.8 for any Job DSL project.
Since Groovy 2.3 is the first version that officially supports Java 8 (see Release notes for Groovy 2.3), it's recommended to use Java 7 for any Groovy 1.8 project.
In my pom.xml I declared the Maven compiler plugin as followed:
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
But m2e does not update the JRE that is used for this project. It still uses Java 1.4. Installed is the JDK 8 update 5. This is the only version that is installed. I am on windows.
Did I miss something? On my Mac I have the same settings and there it works.
Update
I set up a new virtual Windows machine on my Mac and did clean installs of Java 8, Eclipse Kepler SR2 and Maven. Now Maven sets the correct JRE, but Eclipse gives me errors like "Syntax error, X is only available if source level is 1.5 or greater". Project specific settings for the compiler are enabled by m2e and set to 1.7. I also bumped the compiler plugin version to 3.1. I am totally confused. Please help me!
You need to install Java 8 support for Eclipse and Maven via the Eclipse marketplace:
Help > Eclipse Marketplace > Search for "java 8"
Then install the following two plugins:
Java 8 support for Eclipse Kepler SR2
Java 8 support for m2e for Eclipse Kepler SR2
You need to restart Eclipse during the installation.