log4j package does not exist

Go To StackoverFlow.com

0

I'm running mvn install, getting below error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile 

error: package org.apache.log4j does not exist

In my project hierarchy I have log4j-1.2.15.jar added as a Referenced Libraries..not sure what I'm missing.

Part of POM file with log4j dependency (should I change the version to just say 1.2...or possible remove the scope below?):

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>1.2.15</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>1.2.15</version>
    </dependency>
2017-05-29 15:55
by raptor496
This might help you https://stackoverflow.com/questions/8667640/maven-compilation-error-log4 - Rohan 2017-05-29 16:05
is log4j configured as a maven dependency? Adding libraries to Eclipse's build path will not make them available to Maven - Luciano van der Veekens 2017-05-29 16:26
I don't see the dependency in the project POM fil - raptor496 2017-05-29 21:35
Have you tried adding the Log4j dependency in your pom - Sir4ur0n 2017-05-29 22:15
I added the dependency into POM, now I'm getting this error. Maybe the previous error corrected once I added to POM... not sure.

[ERROR] Failed to execute goal on project project1: Could not resolve dependencies for project com.title.proj:project1:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.apache.logging.log4j:log4j-api:jar:1.2.15, org.apache.logging.log4j:log4j-core:jar:1.2.15: Could not find artifact org.apache.logging.log4j:log4j-api:jar:1.2.15 in central (https://repo.maven.apache.org/maven2) -> [Help 1 - raptor496 2017-05-29 22:39

Updated my issue with the part of the POM file abov - raptor496 2017-05-29 22:41
Still getting original erro - raptor496 2017-05-29 23:54
May be you have some old/corrupted versions of log4j jar. In your .m2 directory, if you find dependencies of org.apache.logging, delete them and do a mvn clean installharshavmb 2017-05-30 07:50


1

For log4j I only use this libraries:

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
2017-05-30 07:39
by Liz Lamperouge


0

At first, it can be related with some your customizations of the environment or with dependencies in your *.pom file (Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin (default-compile) on project: Fatal error compiling: tools.jar not found). You need to check default installed "jre" to a jdk. Also ensure maven instalation and , namely paths: $JAVA_HOME and $M2_HOME

for example the paths adjustments when you have linux: enter image description here

When I execute the command: echo $JAVA_HOME I will have /usr/lib/jvm/java-9-oracle and appropriate path for maven

2017-05-29 16:03
by Vasyl Lyashkevych


0

For eclipse users this directly resolved this problem. There is no need to re-install anything with maven installed in eclipse oxygen centos 6. Vogella tutorial below says to resolve the dependency by adding the .jar via downloaded index at startup. As identified above answer 1.2.17 is around the same solution that worked for me (1.2.15) You must launch eclipse in a terminal with JAVA_HOME set as mentioned above. Eclipse will handle the rest.

How to use maven in eclipse

Identifies how to download the dependency list. Once you setup your project you open the pom gui and select Dependencies. You search for the above mentioned library select and add it. During initial build, the dependent .jar is downloaded and configured dynamically via the pom.xml state injection, this is why no manual deleting or re-install is necessary.

It is still not managed- To manage the dependency, i.e. add it to the pom, you select the item you just added and click manage and follow the prompts to add it the Dependency Management list. This is an automatic pom addition from the gui - `

    <dependency>
        <groupId>org.eclipse.ecf</groupId>
        <artifactId>org.apache.log4j</artifactId>
        <version>1.2.15.v201012070815</version>
    </dependency>`  

When the Dependency Management list is populated your library will display a (managed:version) tag in orange.

Start smiling, right click pom, run as maven build, the errors should be gone.

2018-08-29 14:14
by Christopher Hoffman
Ads