At 11:24 AM 1/2/2006 +0100, you wrote:
>
>Hello,
>
>I developed a very simple ear application that includes a web app and a
>stateless EJB.
>
>The EJB uses log4j.
>
>This application runs in weblogic8.1 server. I am using
>log4j-1.2.13.jar.
>
>The ear structure is as follows:
>
>C:\software\bea8\config\local\applications>jar tvf RuleApp.ear
> 0 Mon Jan 02 11:07:56 CET 2006 META-INF/
> 79 Mon Jan 02 11:07:54 CET 2006 META-INF/MANIFEST.MF
> 466 Thu Dec 22 18:13:44 CET 2005 META-INF/application.xml
> 4725 Mon Jan 02 11:07:56 CET 2006 RuleAppWeb.war
> 6955 Mon Jan 02 11:07:56 CET 2006 RuleService.jar
> 0 Mon Jan 02 11:08:02 CET 2006 etc/
> 0 Mon Jan 02 11:08:02 CET 2006 etc/properties/
> 2340 Mon Jan 02 11:08:02 CET 2006 etc/properties/log4j.properties
>358180 Sun Dec 04 19:00:48 CET 2005 log4j-1.2.13.jar
> 1278 Mon Jan 02 11:07:52 CET 2006 utils.jar
>
>Inside the EJB (RuleService), in order to load the log4j.properties
>file, I do:
>
> if (logger == null)
> {
> logger = Logger.getLogger(RuleServiceEJB.class);
> URL propertyFileURL =
>Thread.currentThread().getContextClassLoader().getResource(LOG4J_PROPERT
>Y_FILE);
> if (propertyFileURL != null)
> PropertyConfigurator.configure(propertyFileURL);
> else
> System.out.println ("FATAL, " + LOG4J_PROPERTY_FILE + "
>not found !");
> }
>
>where
> private static final String LOG4J_PROPERTY_FILE =
>"etc/properties/log4j.properties";
>
>but I'm not able to load the log4j.properties file: the propertyFileURL
>is null !
>
Why do you expect that the classloader would have any idea how to find
stuff under the "etc" directory of the EAR? As far as I am aware,
Weblogic's standard EAR structure doesn't include an "etc" directory, but I
could be wrong. Even if it does, the way you have it written assumes that
the root of the EAR is in the classpath, which I'm certain is incorrect.
Try this. Get rid of your initialization logic in your EJB
completely. Put log4j.jar in APP-INF/lib (all *.jar files put in this
directory will get picked up and loaded. This is where you put supporting
libraries. The root of the EAR is for components.) within your EAR
structure and log4j.properties under APP-INF/classes. These are akin to
WEB-INF/lib and WEB-INF/classes in WAR files. Weblogic thought that idea
was good and went with it. It isn't part of any standard spec, but I
guarantee that Weblogic 8.1 supports it (and documents its support for
it). I use it at work. Just let Log4j perform automatic
initialization. It will automatically find log4j.properties in
APP-INF/classes and perform initialization for you.
BTW, if you have troubles, you might try log4j.xml because if log4j.xml
exists in the default package somewhere on the classpath, it will get used
in preference to log4j.properties. This is why I always suggest using the
XML config file. Actually, it's been a running theme of mine over this
last week. Lots of configuration questions.
Jake
>Could someone please help me to understand why ?
>
>Thanks
>Patrizio
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]