I am trying to integrate my maven project with Tomcat server 8.5. Without integration, everything works fine. I replaced maven-compiler-plugin with tomcat7-maven-plugin in pom.xml and did other configurations. After that mvn install, mvn clean install and mvn tomcat7:deploy everything is failing with below exception.
TestServiceCSV.java:[345,48] strings in switch are not supported in -source 1.5
(use -source 7 or higher to enable strings in switch)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
So clearly the compilation is being performed using java 1.5, whereas my jdk version is 1.8.0_144. Additional details below:
>mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T02:58:13-05:00)
Maven home: C:\Maven\apache-maven-3.5.2\bin\..
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_144\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
>java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
I have set the Installed JRE in Eclipse as the JDK. Also the build path for my project reflects same.
>echo $MAVEN_HOME
C:\Maven\apache-maven-3.5.2
>echo $JAVA_HOME
C:\Program Files\Java\jdk1.8.0_144
Tomcat version 8.5.23
POM.xml entry
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>TomcatServer</server>
<username>admin</username>
<password>xxxx</password>
</configuration>
</plugin>
Why could the compilation is being performed on 1.5 instead of the actual version?
Default source level of the compiler plugin is 1.5. The compiler:compile goal is bound to the compile phase of the default lifecycle. You always have to set the source and target levels if you want to use advanced language features from release 6 on.
Related
Immediately after I upgraded my Mac from maven 3.6.0 to 3.6.3 with homebrew, I was no longer able to build my maven project. I've been through torrents of version dependency problems, etc, but I'm hoping to avoid stepping through any more of that stuff than I need to. And before I continue, I wanted to bounce this off of you guys to see if it indicates anything ominous, or if it's ops normal (since I've never paid too much attention to it in the past.) In question is the variance in java version numbers between mvn --version and java -version, i.e., 1.8.0_191 vs 14.0.1:
$ java -version java version "1.8.0_191" Java(TM) SE Runtime
Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM
(build 25.191-b12, mixed mode)
mvn --version Apache Maven 3.6.3
(cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home:
/usr/local/Cellar/maven/3.6.3_1/libexec Java version: 14.0.1, vendor:
N/A, runtime:
/usr/local/Cellar/openjdk/14.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x",
version: "10.15.6", arch: "x86_64", family: "mac"
Thanks in advance!
Turns out my JAVA_HOME variable somehow evaporated in the homebrew upgrade. Once I set that, all 12 million problems disappeared instantly. Thanks for the comment khmarbaise!
maven is pointing to java 1.8, but maven command complains
use -source 8 or higher to enable static interface methods
$mvn -version
Picked up _JAVA_OPTIONS: -Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 19:15:32-0700)
Maven home: /opt/apache-maven-3.1.0
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.el6_8.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.el6.x86_64", arch: "amd64", family: "unix"
echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk.x86_64
Can anyone help point out what is wrong here?
It's hard to tell without seeing an actual pom, but probably you should configure Maven compiler plugin to work with Java 8.
You can see an example of doing this here here.
The easiest way probably would be:
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
i think maven project run on lower version of jdk 8. please check the version, go to project properties>Project Facets> java 1.8 version is select or not... if not then select and apply and run again.
I am not getting any scanning for projects or build successful or build failure message after running typing mvn install or mvn clean install.
LM-SFA-11002477:com.stubhub.mapreduce.hbasehexatodecimal navparmar$ mvn clean install
log4j:WARN No appenders could be found for logger (org.apache.maven.cli.logging.impl.UnsupportedSlf4jBindingConfiguration).
log4j:WARN Please initialize the log4j system properly.
Downloading: https://mvnrepository.stubcorp.dev/nexus/content/groups/stubhub-public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
LM-SFA-11002477:target navparmar$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T12:39:06-07:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
You may have included multiple slf4j jars versions in your project. Please find the dependency hierarchy tab in your pom.xml and exclude the unecessary jar version from your pom.xml.
If you still getting issue then try to build the project in debug mode.So that you will get detailed error description.
mvn clean compile install -X
I'm using Mule CE 3.7, who uses Maven to compile it's project.
The problem is, when is compiling, he returns this error:
[ERROR] Detected JDK Version: 1.8.0-60 is not in the allowed range [1.7,1.8].
I already did all the solutions that i found, JAVA_HOME and PATH are configured.
If i run Java commands, they return me this:
MBP-de-axz:~ axz$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
MBP-de-axz:~ axz$ javac -version
javac 1.8.0_60
MBP-de-axz:~ axz$ mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T08:57:37-03:00)
Maven home: /usr/local/Cellar/maven/3.3.3/libexec
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: pt_BR, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.1", arch: "x86_64", family: "mac"
I already configured the Pom file of my project like this:
<requireJavaVersion>
<version>[1.7,1.9)</version>
</requireJavaVersion>
So all is pointing to the same Java version.
And this is happening in my Mac and Windows.
The project only works if i change to Java 1.7, but i can use 1.7 because one of my libraries uses Java 1.8.
Anyone have an ideia of what could it be ?
Thanks !
You probably want to use [1.7,1.9) as version range. This means it accept version between 1.7 (inclusive) until 1.9 (exclusive). Since 1.8.0_60 is bigger than 1.8, it was out of range with the previous version range. Btw, [1.8) would both include and exclude 1.8, so that shouldn't work.
This error happens, when the maven JDK version and PROJECT JDK version doesn't match.
Inorder to fix that, try to find out the mvn jdk version first using
"mvn --version"
Then set the desired JDK version using set JAVA_HOME="c:\jdk_location_here". If you re-run the "mvn --version". You will see the updated JDK Version there.Now try to run your build.
Long term: Set the JAVA_HOME in environment variables.
The problem is that Mule is not compatible yet with JDK 1.8, i need to use JDK 1.7
I should have read the requeriments.
When I ran the command
mvn clean package
I am getting error:
Detected JDK Version: 1.6.0-24 is not in the allowed range 1.7.
How to fix the above error? I tried to check jdk version isntalled and got this
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
how to fix this?
Normally when execute the mvn -v you may see something like
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da;
2013-02-19 20:51:28+0700)
Maven home: C:\Java.Application\Apache\apache-maven-3.0.5\bin\..
Java version: 1.7.0_15, vendor: Oracle Corporation
Java home: C:\Java.Application\Sun\Java\jdk1.7.0_15\jre
Default locale: en_US, platform encoding: MS874
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
If the result point to the JDK Version: 1.6.0-24 or other than your expect. Please simply set the JAVA_HOME to your JDK Version: 1.7.0_03 instead.
I hope this may help.
Make sure that your environment (PATH) is set up to use the JDK version that you want to use for compiling. You can check this by running the following in the shell or command window where you want to run Maven:
java -version
javac -version
Make sure that both java and javac are pointing to the correct version. It's possible that you have a 1.7 JRE (which does not include the compiler) and a 1.6 JDK (which includes the compiler) and the wrong one is being used.
If necessary, adjust your JAVA_HOME and PATH environment variables.
Just noticed that you're on CentOS - it's possible that java and javac point to different versions. Use the alternatives command to check that, see here for an example: http://wiki.centos.org/HowTos/JavaRuntimeEnvironment - you will have to check both the java and the javac command.
Check your JRE System Library in Eclipse. Does it show jdk1.6.0-24?
For me I had to right click the JRE System Library and go to Build Path -> Configure Build Path, in the Libraries tab I had to click JRE System Library and edit it. I set it to the Workspace Default JRE, which for me is jdk1.7.0_80 (not sure why it wasn't set to that already).