Home > OS >  Unable to find log4j jar parent dependency
Unable to find log4j jar parent dependency

Time:12-15

I am using Maven 3.6.0 and I have Spring Boot Maven project whose pom file as follows :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.myapp</groupId>  
    <artifactId>myAppName</artifactId> 
    <version>1</version>
    <packaging>war</packaging>    

    <parent>   
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>   
    </properties>

    <dependencies>
    
       

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId> 
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>

        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        
        

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-ldap</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-server-jndi</artifactId>
            <version>1.5.7</version>
        </dependency>
        
        
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>8.2.1.jre8</version>
        </dependency>
        
         
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>2.3.9</version>
        </dependency>
        
         
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>10.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>primefaces-extensions</artifactId>
            <version>10.0.0</version>
        </dependency>


        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>resources-ckeditor</artifactId>
            <version>10.0.0</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.ocpsoft.rewrite</groupId>
            <artifactId>rewrite-servlet</artifactId>
            <version>3.4.4.Final</version>
        </dependency>

        <dependency>
            <groupId>org.ocpsoft.rewrite</groupId>
            <artifactId>rewrite-config-prettyfaces</artifactId>
            <version>3.4.4.Final</version>
        </dependency>
        
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.14</version>
        </dependency> 
            
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>
                        
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.6</version>
        </dependency>
        
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.4</version>
        </dependency>
        
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.7</version>
        </dependency>
            
        
            
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version>
        </dependency>
        
        
        <dependency>
          <groupId>org.primefaces</groupId> 
          <artifactId>california-theme</artifactId>
          <version>2.0.1</version>
        </dependency>
        
        <dependency>
          <groupId>SadadMC</groupId> 
          <artifactId>SadadMC</artifactId>
          <version>1.0</version>
        </dependency>
        
        <dependency>
          <groupId>Jace</groupId> 
          <artifactId>Jace</artifactId> 
          <version>5.2.1</version>
        </dependency>
        
        <dependency>
          <groupId>stax-api</groupId> 
          <artifactId>stax-api</artifactId> 
          <version>5.2.1</version>
        </dependency>
        
        <dependency>
          <groupId>xlxpScanner</groupId> 
          <artifactId>xlxpScanner</artifactId> 
          <version>5.2.1</version>
        </dependency>
        
        <dependency>
          <groupId>xlxpScannerUtils</groupId> 
          <artifactId>xlxpScannerUtils</artifactId> 
          <version>5.2.1</version>
        </dependency>
        
        
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
            <version>2.15.0</version>
        </dependency>
        
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>
        
        
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>
            
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.5</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-core</artifactId>
            <version>1.24.1</version>
        </dependency>
        
    </dependencies>
    
    <build>
        <finalName>myAppName</finalName>    
        <plugins>
            
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>          
               <configuration>
                  <argLine>-Dfile.encoding=UTF8</argLine>
                  <skipTests>true</skipTests>
               </configuration>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>${basedir}/src/main/java</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                            <includes>
                                <include>**/*.properties</include>
                                <include>**/*.xml</include>
                                <include>**/*.css</include>
                                <include>**/*.html</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>${basedir}/lib</directory>
                            <targetPath>WEB-INF/lib</targetPath>
                            <includes>
                                <include>**/*.jar</include>
                            </includes>
                        </resource>
                    </webResources>
                    <!--  <outputDirectory>C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps</outputDirectory> -->
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

        </plugins>
         
    </build>
    
    

    <repositories>
    
       <repository>
            <id>java-net-repo</id>
            <url>https://maven.java.net/content/repositories/public/</url>
        </repository>
        
       <repository>
          <id>central</id>
          <name>Central Repository</name>
          <url>https://repo.maven.apache.org/maven2</url>
          <layout>default</layout>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        
        <repository>
            <id>itext-releases</id>
            <name>iText Repository - releases</name>
            <url>https://repo.itextsupport.com/releases</url>
          </repository>
        <repository>
            <id>Enonic</id>
            <name>Enonic</name>
            <url>https://repo.enonic.com/public/</url>
        </repository>
        <repository>
            <id>central-repo</id>
            <name>Central Repository</name>
            <url>http://insecure.repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>org.jboss.repository.releases</id>       
            <name>JBoss Maven Release Repository</name>
            <url>http://repository.jboss.org/nexus/content/repositories/releases</url>
        </repository>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>  
        </repository>
        


    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>

</project>

For some reason I found in my lib folder the following jar log4j-1.2.14.jar. I want to exclude this jar from my final war, so I tried mvn dependency:tree but I couldn't find the parent dependency.

Also I tried to open Dependency Hierarchy from Eclipse but also I couldn't find this jar. How can I exclude this jar?

CodePudding user response:

A dependency that has another dependency that has the scope provided won't lead to that provided dependency being on the classpath. It probably is there because it is needed for testing or building.

So what you should do is check your end deployment unit (your own jar/war) and check if the jar is there in the lib directory. If it is something else is managing/including that dependency. (You can use mvn dependency:tree to figure out which one).

For more information on the Maven scopes, check this. How to include a certain version of Log4j2 (when you are using it) with Spring Boot is described in this Spring.io blog-post.

  • Related