• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

.m2 keeps getting only Log4j when my pom file is Log4j2

 
Ranch Hand
Posts: 523
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi experts,

First problem
---------------
I have been making numerous attempts to make my app use Log4j2 but I keep getting Log4J only from maven...


[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Hi5S ---
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.pom (145 B at 51 B/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar (358 kB at 238 kB/s)
[INFO] Nothing to compile - all classes are up to date



So far, I have tried deleting the entire Log4J folder but when I did Maven Installed after Maven clean, what was downloaded into my local repository .m2 is Log4J

There was this error that I don't understand


Building war: C:\Users\\workspace5\Hi5S\target\Hi5S-0.0.1-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.659 s
[INFO] Finished at: 2018-01-24T18:27:51+08:00
[INFO] Final Memory: 20M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project Hi5S: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
[ERROR]



And no matter how I trawled the internet I can't find any answer

Here's what's inside my pom.xml
--------------------------------------


<groupId>Hi5S</groupId>
<artifactId>Hi5S</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jdbc -->

<dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jdbc</artifactId>
   <version>9.0.2</version>
</dependency>
 
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
       <version>2.10.0</version>
     </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
       <version>2.10.0</version>
     </dependency>





Second problem
-------------------
Furthermore, Eclipse needs me to put in the Log4j2 core and api jars in the build path.  However, I coudn't extract anything from the zip file which I have downloaded.
Inside the zip file I just could not find the log4j2 api and core jars that are required.

Hope someone can point out something that will lead me to a solution to the above problem.

BTW, the update maven dependencies would not stop again - old problem coming back to haunt me again...help.......

I am not sure if what I am facing is normal cos just tackling all these tools' problem really leave me no time for real coding....is this what's happening in the real world ? or it just happens to me ?
 
Sheriff
Posts: 6042
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

tangara goh wrote:I have been making numerous attempts to make my app use Log4j2 but I keep getting Log4J only from maven


It may be that log4j 1.x is needed as a dependency in some other module.  Have you looked in .m2/repository/org/apache/logging/log4j to see if the 2.10 version has already been downloaded?

If it turns out you need both log4j 1.x and 2.10, you may need a bridge of some sort because the two APIs are incompatible.

logging.apache.org wrote:The API for Log4j 2 is not compatible with Log4j 1.x, however an adapter is available to allow applications to continue to use the Log4j 1.x API.  

 
Knute Snortum
Sheriff
Posts: 6042
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There was this error that I don't understand ...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project Hi5S: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]  


Well, the error message is moderately clear.  Do you have a WEB-INF/web.xml file setup?  And if not, the maven-war-plugin section of your POM will need a webxml attribute.

[Edit] I think posting your entire POM file will help.  And use the Code button with the pulldown selector set to XML.
 
Knute Snortum
Sheriff
Posts: 6042
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Furthermore, Eclipse needs me to put in the Log4j2 core and api jars in the build path.  However, I coudn't extract anything from the zip file which I have downloaded.
Inside the zip file I just could not find the log4j2 api and core jars that are required.  


You shouldn't have to do this if you have the Maven Eclipse plugin M2E.  
 
Knute Snortum
Sheriff
Posts: 6042
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am not sure if what I am facing is normal cos just tackling all these tools' problem really leave me no time for real coding....is this what's happening in the real world ? or it just happens to me ?


I think everyone runs into problems that stump them for a while.  Learning a new technology has a learning curve to it.  Keep at it!  It will get easier.
 
Ranch Hand
Posts: 36
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

tangara goh wrote:Hi experts,
First problem
---------------
I have been making numerous attempts to make my app use Log4j2 but I keep getting Log4J only from maven...


It must be coming as transitive dependency from some other jar, please check dependency hierarchy tab in your IDE to find this out.

tangara goh wrote:
So far, I have tried deleting the entire Log4J folder but when I did Maven Installed after Maven clean, what was downloaded into my local repository .m2 is Log4J


Do you really need to use Maven Install there?
Just do maven compile and check. Besides, m2e plugin automatically builds the project for you, if it doesn't just use build/clean option from the IDE.

tangara goh wrote:
There was this error that I don't understand
Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
[ERROR]


If you do not require web.xml, please use following configuration in your pom.xml



tangara goh wrote:
Furthermore, Eclipse needs me to put in the Log4j2 core and api jars in the build path.  However, I coudn't extract anything from the zip file which I have downloaded.
Inside the zip file I just could not find the log4j2 api and core jars that are required.

Hope someone can point out something that will lead me to a solution to the above problem.

BTW, the update maven dependencies would not stop again - old problem coming back to haunt me again...help.......

I am not sure if what I am facing is normal cos just tackling all these tools' problem really leave me no time for real coding....is this what's happening in the real world ? or it just happens to me ?



M2E should do the work for you, try to work with Dependency Hierarchy tab in your IDE and exclude the dependencies you are having conflict with.

There was trouble earlier while configuring a web app with Spring, that's the reason spring boot came into picture.
Keep trying, things are going to work in a while.
 
Bartender
Posts: 20849
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When an app pulls lots of JARs into its build, you can get the equivalent of "DLL Hell" where some JARs conflict with others. Not only are there version conflicts, you can have technology conflicts. The slf4j project came as a result of people wanting to build projects from components with different loggers (log4j, juli, apache logger).

This is one of the reasons why Maven is designed with the idea that you pull specific versions of JARs into your project instead of just going with the latest version of everything.

Sometimes you just have to sit down with a dependency graph, determine what the commonly-acceptable JAR set is and define your project's dependencies accordingly.

And on rare occasions, you may simply not be able to find such a happy medium. In which case you either have to wait for someone to come up with JAR(s) that can be reconciled or solve it yourself the hard way.

And the best of it is that if you intend to keep up with technology, you'll end up having to do the whole thing again in a year or so!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!