Log4j: ERROR

Answered

I got  a gwt project and I use gwt run configuration to run the application. Recently I upgraded gwt library from version 2.5.0 to 2.7.0. After the gwt  library upgrade, I lost console logging with the following message. I have log4j.jar in my web app but no idea how/where sun.misc.Launcher$AppClassLoader is loading "org.apache.log4j.Appender" class (from). Any would be appreciated. 

============ Error while running running app from gwt run configuration ============ 

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [sun.misc.Launcher$AppClassLoader@4d885088] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebAppClassLoader=Lynx Reservations (Jag Client) - ${bamboo.build}@6fcaf06b].
log4j:ERROR Could not instantiate appender named "stdout".

===============Contents of log4j.properties file ==================

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} [%t] %-5p [%F:%L] : %m%n

### set standard log levels ###
log4j.rootLogger=WARN, stdout
log4j.logger.com.lynxtraveltech=debug

0
5 comments

Do you use any build system (Maven , Gradle)? Please check that your classpath doesn't contain 2 copies of log4j library.

0
Avatar
Permanently deleted user

Yes I use Maven build system. 

I checked all three following places in IntelliJ but I got only one copy of log4j.jar (log4j-1.2.13.jar) 

  • External Libraries in Project window
  • Modules Dependencies in "Project Structure" window
  • Module dependencies in "Maven Projects" window. 

I have noticed a log4j.jar in IntelliJ home lib directory

0

Please check the command line when the app is started, do you see multiple log4j jars added there? Compare it to the classpath of your app before GWT update.

0
Avatar
Permanently deleted user

I checked both command lines and no multiple log4j.jar is found. But I noticed that IntelliJ generated different command lines with different parameters at starts and ends. I am running IntelliJ version 2017.3. with maven 3.04 and jdk 1.7.0_75

=========== gwt 2.5 command line ============= 
$JAVA7_HOME\bin\java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63450,suspend=y,server=n -Xms1024m -Xss1024k -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=256m -Dgwt.codeserver.port=9876 -javaagent:$USER_HOME\.IntelliJIdea2017.3\system\captureAgent\debugger-agent.jar=$USER_HOME\AppData\Local\Temp\capture2.props -Dfile.encoding=UTF-8 -classpath "................................" com.google.gwt.dev.DevMode -war $USER_HOME\.IntelliJIdea2017.3\system\gwt\lynx.f97cf92b\jag-client.a1b3282b\run\www -remoteUI 7901:IntelliJIdea -startupUrl client.jsp com.lynxtraveltech.client.JagClient

========== gwt 2.7 command line =============
$JAVA7_HOME\bin\java -Xms1024m -Xss1024k -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=256m -Dgwt.codeserver.port=9876 "-javaagent:$IDEA_HOME\lib\idea_rt.jar=49423:$IDEA_HOME\bin" -Dfile.encoding=UTF-8 -classpath ..................... com.google.gwt.dev.DevMode -nosuperDevMode -war $IDEA_HOME\system\gwt\lynx.7cf48f67\jag-client.dedeb8e7\run\www -remoteUI 7901:IntelliJIdea -startupUrl client.jsp com.lynxtraveltech.client.JagClient

 

0
Avatar
Permanently deleted user

Hello,

I noticed that for gwt 2.5 you have debug Run Configuration while for gwt 2.7 you have regular one.

In second case there's IDEA runtime agent configured with this line: "-javaagent:$IDEA_HOME\lib\idea_rt.jar=49423:$IDEA_HOME\bin". It might load its own log4j, so please try using debug mode, it should help.

0

Please sign in to leave a comment.