aspose file tools*
The moose likes Other Open Source Projects and the fly likes Jar hell concerning log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jar hell concerning log4j" Watch "Jar hell concerning log4j" New topic
Author

Jar hell concerning log4j

R Flores
Greenhorn

Joined: Jun 17, 2010
Posts: 4

Hello all,

I use Taverna 1.7.2 and specifically the bootstrap jar 1.7.2.1. I want to run it from my web application (war, named ProticPort) launched by jetty-runner.jar, but I get a conflict when I try to execute a workflow (via Taverna bootstrap). I have my own log4j jar embedded into my webapp with my config, and it seems that Bootstrap get its own too, which lead to a jar hell and make my app shuting down, as you can see below when I try to execute simple example workflow "file:/taverna/taverna-1.7.2/examples/fetch_today_s_xkcd_comic.xml" with Boostrap.main(workflowArgs):

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 [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "rollingFile".
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "rollingFile".
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 [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "stdout".
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 [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "rollingFile".
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 [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "rollingFile".
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 [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "rollingFile".
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 [loader{log4j:log4j:1.2.12} from 31539877] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ContextLoader@Archetype Created Web Application : ProticPort].
log4j:ERROR Could not instantiate appender named "CONSOLE".
Unable to determine file for log4j.properties
log4j:WARN No appenders could be found for logger (net.sf.taverna.utils.MyGridConfiguration).
log4j:WARN Please initialize the log4j system properly.
2010-06-16 19:11:57.440:INFO::Shutdown hook executing



Does anyone of you know how to avoid such a jar hell ? Is it possible to disable log for Taverna in order Bootstrap runs correctly ?

For information, I include bootstrap class with maven pom.xml. Running bootstrap jar from command line works correctly.

Any help would be greatly appreciated.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi there and welcome to Javaranch! I'm a little confused, where exactly is the log4j.jar that the bootstrap is using?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
R Flores
Greenhorn

Joined: Jun 17, 2010
Posts: 4


Thanks for your welcome.

log4j.jar is in $jar/WEB_INF/lib/ folder, as taverna-bootstrap.jar. I guess bootstrap uses log4j.jar present in lib directory because bootstrap jar does not contain any third party library.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 193

Check if you are having multiple log4j.xml files in your workspace/application.

Playing around log4j.xml will definitely resolve your problem.


SCJP 5, SCWCD 5
R Flores
Greenhorn

Joined: Jun 17, 2010
Posts: 4

Hi. I've checked and indeed there is another minimal-log4j.properties in taverna-core jar embedded into my war lib folder: ./taverna-core-1.7.2.1/minimal-log4j.properties (once extracted).

I have deleted this file and another one contained into another embedded jar (Jmol).

To find these files, I have exploded all embedded jar and taken a look into them:



But, even if I remove all other log4j configuration files, I still get the error:



For information, here is my log4j.properties file:



I don't see what is currently causing trouble, any hints is welcome.

Thanks for your help.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 193

Why don't you use log4j.xml instead of log4j.properties?

That gives you a clear configurations than properties file.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You also need to think about class loading and the scope of your classes. e.g. Jboss Application Server has a log4j.jar and log4j.xml that it uses by default. To supply our own with our deployed EAR files we had to ensure that we bundled our own log4j.xml and own log4j.jar and then told the EAR to consider those first in class loading.
R Flores
Greenhorn

Joined: Jun 17, 2010
Posts: 4

@Prabhakar Bokka: I don't use log4j.xml because of historical facts for this webapp. XML migration may be done later if needed and if dedlines allow it.


Martijn Verburg wrote:To supply our own with our deployed EAR files we had to [...] told the EAR to consider [our own log4j.xml and own log4j.jar] first in class loading.


Ok, where and how do you do this please ?
 
wood burning stoves
 
subject: Jar hell concerning log4j