im trying to get configure code that works in dual-use components ( java
app. or WebApp ).

My question is at bottom of post...

The following configure code works fine in a WebApp on TomCat
* * * * * * *
java code causing the exception : PropertyConfigurator
* * * * * * *

    static
    {
                ClassLoader cl = MyFileFilter.class.getClassLoader();
                PropertyConfigurator.configure(
                  cl.getResource(
                    "/log4j.properties"
                  )
                );
    }

When run from the command line in Win2000 using j2sdk1.4.2 however, the
above code causes the following exception in class=MyFileFilter.

Exception in thread "main" java.lang.ExceptionInInitializerError
        at com.borneo.util.FileSelector.getFiles(FileSelector.java:25)
        at com.borneo.net.soap.SAAJCallMgr.putFile(SAAJCallMgr.java:103)
        at com.borneo.net.soap.SAAJCallMgr.main(SAAJCallMgr.java:140)
Caused by: java.lang.NullPointerException
        at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:
424)
        at
org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:32
7)
        at com.borneo.util.MyFileFilter.<clinit>(MyFileFilter.java:120)
        ... 3 more

The offending class was loaded from a JAR file that contained the
log4j.properties file in ROOT...

* * * * * * *
jar file also contains the property file
* * * * * * *

        -1 Jun 18 2003 17:58 com/borneo/util/MyFileFilter.class
        -1 Jun 18 2003 17:58 com/borneo/util/POProperty.class
        -1 Jun 18 2003 14:30 ftp.properties
        -1 Apr 27 2003 08:46 log4j.properties

Not only was the log4j.properties file in the same jar, but it is also
contained in the Root Directory where the command-line invoked the JVM...
* * * * * * *
root directory where java app. run also contains the property file
* * * * * * *
 Directory of J:\po_1_2\config

06/18/2003  02:30p               1,911 ftp.properties
06/03/2003  08:58a               1,817 ftp.properties.ol
04/27/2003  08:46a               1,052 log4j.properties

Command Line launching the JVM...
J:\po_1_2\config>%java_home%\bin\java -cp "%CLIENTCLASSPATH%;."
com.borneo.net.soap.SAAJCallMgr ftp.properties
 http://localhost:8080/axis/services/urn:EchoAttachmentsService

with setter for CP...

set
CLIENTCLASSPATH=F:\axis-1_1RC2\lib\axis.jar;F:\axis-1_1RC2\lib\commons-disco
very.jar;F:\axis-1_1RC2\lib\commons-logging.jar;F:\axis-1_1RC2\lib\jaxrpc.ja
r;F:\axis-1_1RC2\lib\saaj.jar;F:\axis-1_1RC2\lib\xml-apis.jar;F:\axis-1_1RC2
\lib\xercesImpl.jar;F:\axis-1_1RC2\lib\wsdl4j.jar;F:\jwsdp-1.2\jaxp\lib\jaxp
-api.jar;F:\jwsdp-1.2\jaxp\lib\endorsed\xercesImpl.jar;F:\jwsdp-1.2\jaxp\lib
\endorsed\xalan.jar;F:\jwsdp-1.2\jaxp\lib\endorsed\xml-apis.jar;F:\jwsdp-1.2
\jaxp\lib\endorsed\sax.jar;F:\jwsdp-1.2\jaxp\lib\endorsed\dom.jar;F:\jwsdp-1
.2\jwsdp-shared\lib\activation.jar;F:\jwsdp-1.2\jwsdp-shared\lib\mail.jar;F:
\jwsdp-1.2\jwsdp-shared\lib\jax-qname.jar;F:\jwsdp-1.2\jwsdp-shared\lib\name
space.jar;F:\j2sdkee1.4\lib\j2ee.jar;F:\jakarta-log4j-1.2.8\dist\lib\log4j-1
.2.8.jar;J:\ftp-bin-bundle\jftp.jar;J:\po_1_2\src\apps\util\dist\util.jar;J:
\po_1_2\src\apps\net\dist\net.jar;J:\po_1_2\src\apps\events\dist\events.jar;
J:\po_1_2\src\apps\client\dist\client.jar;J:\po_1_2\config

 end OF CP * * * *

The following configure code works fine on command line but not in WebApp
* * * * * * *
java code that works OK in app. but not in WebApp
* * * * * * *

                PropertyConfigurator.configure(
                        SAAJCallMgr.class.getResource(
                                "/log4j.properties"
                        )
                );

DOES THE COMPONENT NEED TO REFLECT WHAT ITS RUN-TIME ENVIRONMENT IS (
CMD-Line, or Servlet-Context ) prior to configuring the LOG appender or is
there a single version of the code to configure LOG4J that works in either
context??
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.490 / Virus Database: 289 - Release Date: 6/16/2003


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to