Re: Initializing log4j is causing a NPE
Re: Initializing log4j is causing a NPE
- Subject: Re: Initializing log4j is causing a NPE
- From: Chuck Hill <email@hidden>
- Date: Wed, 23 Jan 2008 09:38:43 -0800
I am pretty sure that the Resources part of the path is assumed, try
taking it off.
Chuck
On Jan 23, 2008, at 5:09 AM, David Avendasora wrote:
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);
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:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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