简体   繁体   中英

jul-to-log4j-bridge “mvn package” ends with “package org.apache.log4j.plugins does not exist” COMPILATION ERROR

Good Day,

I try to build "jul-to-log4j-bridge" jar file using Apache Maven 3.6.0 (Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: C:\\Program Files\\Java\\jdk1.8.0_181\\jre) The aim is to redirect JUL to log4j 1.2.17.

I'm brand new in the java dev world, and have no real background, but : I installed svn OK I gathered sources from http://svn.apache.org/repos/asf/logging/sandbox/jul-to-log4j-bridge/ usign svn (svn export http://svn.apache.org/repos/asf/logging/sandbox/jul-to-log4j-bridge/ ) I installed JDK 1.8.0_181 OK I installed maven 3.6.0 OK

I modified versions of build.plugins.plugin, because they where missing :

[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 102, column 15 [WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:cobertura-maven-plugin is missing. @ line 109, column 15 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-checkstyle-plugin is missing. @ line 92, column 15 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 152, column 15

usign this kind of command : mvn help:describe -DartifactId=cobertura-maven-plugin -DgroupId=org.codehaus.mojo => I modified pom.xml

But I stumble on the concepts of import / packages / plugins etc ... of maven as the error message I got from "mvn package" is :


[INFO] -------------< org.apache.logging:apache-jul-log4j-bridge >-------------
[INFO] Building java.util.logging to log4j Bridge 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ apache-jul-log4j-bridge ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ apache-jul-log4j-bridge ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to C:\Users\llv\Documents\@D\Part\maven\svn\jul-to-log4j-bridge\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/llv/Documents/@D/Part/maven/svn/jul-to-log4j-bridge/src/main/java/org/apache/log4j/jul/JULReceiver.java:[19,32] package org.apache.log4j.plugins does not exist

Can someone please help to pass trough this ? this is about JULReceiver.java.. Any help really appreciated.

thank you

Searching , googling, I founded :

https://logging.apache.org/log4j/extras/

https://logging.apache.org/log4j/extras/apidocs/org/apache/log4j/component/plugins/Receiver.html

And bingo! package "org.apache.log4j.plugins" does not exist in apache-log4j-extras 1.2.17

but package "org.apache.log4j.component.plugins" does ! So I updated JULReceiver.java from :

import org.apache.log4j.plugins.Plugin;
import org.apache.log4j.plugins.PluginSkeleton;

to:

import org.apache.log4j.component.plugins.Plugin;
import org.apache.log4j.component.plugins.PluginSkeleton;

and compilation is successfull

[INFO] --- maven-source-plugin:3.0.1:jar (default) @ apache-jul-log4j-bridge ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.813 s
[INFO] Finished at: 2018-11-08T09:43:07+01:00
[INFO] ------------------------------------------------------------------------

but now tomcat 7.0.23 stops without saying nothing more than :

1/ I set the jar in the classpath: D:\\appli\\tomcat\\instances\\desktop11\\lib\\apache-jul-log4j-bridge-1.0.0-SNAPSHOT.jar;

2/ I configured all applications using JUL in JVM to use the "apache-jul-log4j-bridge" JVM parameters:

-Djava.util.logging.manager=org.apache.logging.julbridge.JULBridgeLogManager

instead of the "classic":

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

JVM starts on : D:\\opt\\jdk1.7.0_80\\jre\\bin\\server\\jvm.dll

I guess tomcat (it uses JUL internally) does not supports this java.util.logging.manager ..

or maybe because of this error at compilation (not blocking) about which I seen infos on stackoverflow , but the fix given leads to another pb (I will seach more..)

[INFO] Compiling 9 source files to C:\Users\llv\Documents\@D\Part\maven\svn\jul-to-log4j-bridge\target\test-classes
[WARNING] /C:/Users/llv/Documents/@D/Part/maven/svn/jul-to-log4j-bridge/src/test/java/org/apache/logging/julbridge/MockAppender.java: C:\Users\llv\Documents\@D\Part\maven\svn\jul-to-log4j-bridge\src\test\java\org\apache\logging\julbridge\MockAppender.java uses unchecked or unsafe operations.
[WARNING] /C:/Users/llv/Documents/@D/Part/maven/svn/jul-to-log4j-bridge/src/test/java/org/apache/logging/julbridge/MockAppender.java: Recompile with -Xlint:unchecked for details.

But by the way can someone help me ? thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM