• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Initializing log4j is causing a NPE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initializing log4j is causing a NPE


  • Subject: Re: Initializing log4j is causing a NPE
  • From: Asa Hardcastle <email@hidden>
  • Date: Wed, 23 Jan 2008 09:07:30 -0500

Hi David,

When I am testing a class outside of the context of wo, I do it this way:

// Properties file config
URL configURL = new URL("file:Resources/ MyFunAndExcitingLog4jConfigFileThatEveryoneWouldBeJealousOf .properties");
PropertyConfigurator.configure(configURL);


or for xml

// XML Based config
URL configURL = new URL("file:Resources/ MyFunAndExcitingLog4jConfigFileThatEveryoneWouldBeJealousOfInBadAssXMLFormat .xml");
DOMConfigurator.configure(configURL);



I place this code in main() because then it will not be called when the Application uses the object, but you can also place it inside of static { }. I imagine the same code will work in your Application constructor.


later,

asa


On Jan 23, 2008, at 8:15 AM, Daniele Corti wrote:



2008/1/23, David Avendasora <email@hidden>:
I'm sure I'm missing something obvious, but

resourceManager().pathURLForResourceNamed( "Resources/log4j.xml" , null, null)

in my Application.java class is returning null when I run my app. The log4j.xml is in the /Resources/ directory (in both the build and dist directories) and flagged as a Resource. Why isn't it being found? It seems to be an intermittent problem as it has done this before and then suddenly started working.

I get the following NPE in Eclipse Run Log:

[2008-01-23 07:47:16 EST] <main> A fatal exception occurred: null
[2008-01-23 07:47:16 EST] <main> java.lang.NullPointerException
at com .bestmaid .bakeryManagement.server.Application.<init>( Application.java:38 )
at sun.reflect.NativeConstructorAccessorImpl.newInstance0( Native Method )
at sun .reflect .NativeConstructorAccessorImpl .newInstance( NativeConstructorAccessorImpl.java:39 )
at sun .reflect .DelegatingConstructorAccessorImpl .newInstance( DelegatingConstructorAccessorImpl.java:27 )
at java.lang.reflect.Constructor.newInstance( Constructor.java:494 )
at java.lang.Class.newInstance0( Class.java:350 )
at java.lang.Class.newInstance( Class.java:303 )
at com.webobjects.appserver.WOApplication.main( WOApplication.java: 323 )
at com .bestmaid.bakeryManagement.server.Application.main( Application.java: 23 )


I get the following from Tomcat when it tries to start the deployed application:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method)
at sun .reflect .NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:39 )
at sun .reflect .DelegatingMethodAccessorImpl .invoke( DelegatingMethodAccessorImpl.java:25 )
at java.lang.reflect.Method.invoke( Method.java:585)
at com .webobjects .jspservlet.WOServletAdaptor._applicationInit( WOServletAdaptor.java: 415 )
at com .webobjects .jspservlet.WOServletAdaptor.initStatics( WOServletAdaptor.java:78 )
at com .webobjects.jspservlet.WOServletAdaptor.init( WOServletAdaptor.java: 629 )
at javax.servlet.GenericServlet.init( GenericServlet.java:212)
at org .apache .catalina.core.StandardWrapper.loadServlet( StandardWrapper.java: 1161 )
at org.apache.catalina.core.StandardWrapper.load( StandardWrapper.java: 981 )
at org .apache .catalina.core.StandardContext.loadOnStartup( StandardContext.java: 4045 )
at org.apache.catalina.core.StandardContext.start( StandardContext.java: 4351 )
at org .apache .catalina.core.ContainerBase.addChildInternal( ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild( ContainerBase.java: 771)
at org.apache.catalina.core.StandardHost.addChild( StandardHost.java: 525)
at org .apache .catalina.startup.HostConfig.deployDescriptor( HostConfig.java:626)
at org .apache .catalina.startup.HostConfig.deployDescriptors( HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java: 488)
at org.apache.catalina.startup.HostConfig.start( HostConfig.java:1138)
at org .apache.catalina.startup.HostConfig.lifecycleEvent( HostConfig.java: 311)
at org .apache .catalina .util.LifecycleSupport.fireLifecycleEvent( LifecycleSupport.java:117 )
at org.apache.catalina.core.ContainerBase.start( ContainerBase.java: 1053)
at org.apache.catalina.core.StandardHost.start( StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start( ContainerBase.java: 1045)
at org.apache.catalina.core.StandardEngine.start( StandardEngine.java: 443)
at org.apache.catalina.core.StandardService.start( StandardService.java: 516 )
at org.apache.catalina.core.StandardServer.start( StandardServer.java: 710)
at org.apache.catalina.startup.Catalina.start( Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method)
at sun .reflect .NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:39 )
at sun .reflect .DelegatingMethodAccessorImpl .invoke( DelegatingMethodAccessorImpl.java:25 )
at java.lang.reflect.Method.invoke( Method.java:585)
at org.apache.catalina.startup.Bootstrap.start( Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main( Bootstrap.java:413)
Caused by: com.webobjects.foundation.NSForwardException [java.lang.NullPointerException] null: <com.bestmaid.bakeryManagement.server.Application> failed instantiation. Exception thrown :
java.lang.NullPointerException : null
at com .webobjects .foundation ._NSUtilities._explainInstantiationException( _NSUtilities.java:567)
at com .webobjects .foundation._NSUtilities.instantiateObject( _NSUtilities.java:581)
at com .webobjects .appserver.WOApplication.primeApplication( WOApplication.java:411)
... 34 more


If I comment the following out of the Application.java file, it will launch:

URL configURL = resourceManager().pathURLForResourceNamed("Resources/ log4j.xml", null, null );
NSLog.out .appendln("Initializing log4j from " + configURL.toString());
DOMConfigurator.configure(configURL);


try:
resourceManager().pathURLForResourceNamed( "log4j.xml", null, null)

Thanks,

Dave

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden )
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden



--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden

--
Computers are like air conditioners -- they stop working properly if you open
WINDOWS


--
What about the four lusers of the apocalypse? I nominate:
"advertising", "can't log in", "power switch" and "what backup?"
--Alistair Young _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@zenn.net


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Initializing log4j is causing a NPE
      • From: David Avendasora <email@hidden>
References: 
 >Initializing log4j is causing a NPE (From: David Avendasora <email@hidden>)
 >Re: Initializing log4j is causing a NPE (From: "Daniele Corti" <email@hidden>)

  • Prev by Date: Re: Help deploying in Eclipse
  • Next by Date: Re: WOLips: Project Triangles do not work.
  • Previous by thread: Re: Initializing log4j is causing a NPE
  • Next by thread: Re: Initializing log4j is causing a NPE
  • Index(es):
    • Date
    • Thread