I have recently installed Maven on my windows based laptop. But getting following error when running mvn just to test my installation:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Whoever when running mvn -version I am getting appropriate response:
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T22:29:23+05:00)
Maven home: C:\apps\Maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Note that I am getting exactly same error when running mvn install, mvn package, mvn clean or any other Maven target in my maven project, while project doesn't have any dependency for SLF4J.
This error usually means that you have the slf4j-api library in your classpath without an SLF4J binding associated with it. Make sure to have exactly one of these binding jars in your classpath alongside the slf4j-api jar (also make sure the versions are compatible):
slf4j-nop.jar,
slf4j-simple.jar,
slf4j-log4j12.jar,
slf4j-jdk14.jar or
logback-classic.jar
The SLF4J lists all such error codes on its FAQ page. You can find this issue and resolution documented here.
IIRC, this is merely a warning and won't affect your build process - or does it? If you didn't really mean to include the SLF4J libraries in your classpath, they would have been pulled in transitively. Use the mvn dependency:tree or the m2eclipse's Dependency Hierarchy view to find the source of these the SLF4J related libraries and exclude them.
Related
I am trying to use Log4j2.10 and slf4j-api 1.8 beta1 in my eclipse project.
I cannot get the binding to work,slf4j complains with:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
It worked with Log4j 2.9.1 and slf4j-api 1.7.24 which was using the StaticLoggerBinder mechanism which is no longer supported in slf4j 1.8
My eclipse plugin depends on
org.apache.logging.log4j.osgi,
org.apache.logging.log4j.api,
org.apache.logging.log4j.core,
org.apache.logging.log4j.slf4j-impl,
slf4j.api
The problem is that in the LoggerFactory (slf4j-api) the ServiceLoader.load(SLF4JServiceProvider.class) call returns any empty list, so the spi file of the org.apache.logging.log4j.slf4j-impl is not found or not loaded.
Is there anything I am missing to get this working?
Thanks in advance,
Rob
You can use org.apache.logging.log4j: log4j-slf4j18-impl for binding with SLF4J 1.8.x, as mentioned in this official documentation.
Log4j2 does is not yet compatible with slf4j-api version 1.8.x which now uses the ServiceLoader mechanism as enforced by JPMS/jigsaw/Java9 modules.
I know that there are similar topics upon this issue but none of them helped me to solve the errors...
I am on a Spring 2.5 project using:
1) Maven 3.3.9:
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: es_AR, platform encoding: UTF-8
OS name: "linux", version: "4.8.0-52-generic", arch: "amd64", family: "unix"
And while running mvn jetty:run I got the following issue:
[ERROR] Nested in org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.IllegalStateException: AnnotationTransactionAttributeSource is only available on Java 1.5 and higher:
java.lang.IllegalStateException: AnnotationTransactionAttributeSource is only available on Java 1.5 and higher
I even change the compiler plugin and set it to java 1.6 as this spring version doesnt work with java 8 and things dont work... Does anyone have a clue ?... I am on Eclipse and also change the compliance level and nothing... no success
I think your $JAVA_HOME environment variable is the problem.
It should contain /usr/lib/jvm/java-8-oracle
instead of /usr/lib/jvm/java-8-oracle/jre
Also, I'm guessing your $PATH contains another, older java version.
You can test that by executing java --version on the command line.
While running a build in Jenkins Maven is complaining about JDK. I know very well that it's some challenge with env variables. I have set JAVA_HOME to JDK installation path but no luck. I have searched the whole web and know that other people have faced this but their solution isn't working for me. Any help would be really appreciated !
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
FYR, my maven version output.
root#zarvis:~# mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: /usr/local/apache-maven-3.3.3
Java version: 1.7.0_101, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-31-generic", arch: "amd64", family: "unix"
JAVA_HOME is set but not sure why maven appends it with JRE.
root#zarvis:~# echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-amd64
Thanks in advance !
Try adding JDK_HOME to your path
When I try to compile a project with Maven I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
My JAVA_HOME is pointing to the JDK:
$ echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
$ $JAVA_HOME/bin/javac -version
javac 1.7.0_25
javac: no source files
Usage: javac <options> <source files>
I'm not sure why Maven adds '/jre' to the end of JAVA_HOME, but looking at some other posts this doesn't seem to be the problem:
$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 18:44:56+1000)
Maven home: /Users/jerry/dev/springsource/apache-maven-3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"
I've searched for a solution to this problem and tried different things for the last couple of days, but can't find anything that works. I've seen some threads with a similar problem, but none of the suggestions worked for me.
Does anyone know how to solve this? Any help greatly appreciated...
You should assign the real path to the JDK to the JAVA_HOME variable instead of leaving the CurrentJDK literal. For some reason in Mac OS X the CurrentJDK is not pointing to the actual one regarding Maven. Try something like this in your .profile but replacing you actual jdk folder name:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
FYI, one cause of "no source files" is lack of disk space wherever tmp points.
Looks like maven and javac store some items in TEMP/TMP/TMDIR and if that director doesn't exist, lacks space, lacks permissions then you can see that problem. at least we did on windows and I suspect it'll happen on better operating systems too.
I'm new to maven. I just joined a new company and they use maven for all their projects.
I set up the company's server for maven dependencies.
I'm using Fedora.
For most of the projects everything goes well. For some of them I get this error when running mvn compile:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project xlayer: Fatal error compiling: Error while executing the external compiler. Error while executing process. Cannot run program "java -classpath "${env.M2_REPO}/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar" org.eclipse.jdt.internal.compiler.batch.Main -sourcepath "src/main"" (in directory "/home/es/ion_projects/XLayer"): error=2, No such file or directory -> [Help 1]
I looked several hours on the web, nothing would do.
PATH and JAVA_HOME are correctly set.
Running mvn --version gives:
Apache Maven 3.0.4 (rNON-CANONICAL_2013-01-22_13-18_mockbuild; 2013-01-22 14:18:29+0100)
Maven home: /usr/share/maven
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: /home/es/kit/jdk1.7.0_17/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.3-103.fc17.i686", arch: "i386", family: "unix"
UPDATE:
In the pom.xml (of parent, but that is not important), the maven-compiler-plugin defined the executable as
java -classpath "${env.M2_REPO}/org/eclipse/jdt/core/${org.eclipse.jdt.core.version}/core-${org.eclipse.jdt.core.version}.jar" org.eclipse.jdt.internal.compiler.batch.Main -sourcepath "src/main"
in order to use the Eclipse compiler instead of sun's comiler. This worked for developpers using windows. On linux, maven tries to execute "java -classpath ...." as a single command, which does not exist.
I am still loking for a solution. the only hack I found was to put the executable "java -classpath ..." in an executable file on my machine and put the name of that file in the tag on maven.