• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loading Log4j.jar from another Jar

 
Ranch Hand
Posts: 62
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I intend to create a common jar which contains all Java Classes related to implementing log4j logging functionality.I have implemented Singleton (GoF) design pattern in a class SLogger to return single instance of log4j across the application.
I have created customlogger.jar file with all class files related to log4j logging and lib folder containing log4j-1.2.8.jar file.
Following shows the directory structure :
-customlogger
----src/
------com.vilpesh.logger
----lib/
------log4j-1.2.8
----META-INF
------MANIFEST.MF

Contents of MANIFEST.MF is
Manifest-Version: 1.0
Class-Path: lib/log4j-1.2.8.jar

When i add the customlogger.java in my other application and try to make use of logging functionality i get following error

java.lang.NoClassDefFoundError: org.apache.log4j.PropertyConfigurator

My other application is deployed in a Websphere application server 6.1.

In the Class SLogger, i have a code statement,which raises error
PropertyConfigurator.configure("C://log4j.properties");

Is it possible to refer to log4j.jar from customlogger.jar?
I want to make any application in the world to be making use of customlogger.jar.
I think the J2EE application server can load the customlogger.jar but it cannot somehow load log4j.jar
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your webapp's WEB-INF/lib folder you should have both customlogger.jar and log4j.jar. Check that for a start.

(I didn't get the part about you implementing a singleton so you could have a single instance of log4j. That seemed pointless to me because log4j already does that sort of thing internally. But maybe you did that to solve a real problem you were having.)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic