DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12242>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12242

ActionServlet fails to find struts-config.xml

           Summary: ActionServlet fails to find struts-config.xml
           Product: Struts
           Version: 1.1 Beta 2
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Controller
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Running Tomcat 4.0.1, JDK 1.3.1, all required .jar files. The application in 
question is called "strutstest". In the WEB-INF directory under this 
application's home directory is the web.xml and the struts-config.xml file. When 
the application is run, the following messages are generated:

[INFO] PropertyMessageResources - -Initializing, 
config='org.apache.struts.util.LocalStrings', returnNull=true
[INFO] PropertyMessageResources - -Initializing, 
config='org.apache.struts.action.ActionResources', returnNull=true
java.lang.NullPointerException
        at strutstest.Trace.initApplicationConfig(Trace.java:85)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852)
        at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3267
)
        at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:3384)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
        at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:307)
        at 
org.apache.catalina.core.StandardService.start(StandardService.java:388)
        at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:505)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:776)
        at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
        at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
[ERROR] ActionServlet - -Parsing error processing resource path 
/WEB-INF/struts-config.xml <java.lang.NullPointerException>
StandardWrapper[:action]: Marking servlet action as unavailable
StandardContext[]: Servlet  threw load() exception: 
javax.servlet.UnavailableException: Parsing error processing resource path 
/WEB-INF/struts-config.xml
javax.servlet.UnavailableException: Parsing error processing resource path 
/WEB-INF/struts-config.xml
        at strutstest.Trace.initApplicationConfig(Trace.java:94)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852)
        at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3267
)
        at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:3384)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
        at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:307)
        at 
org.apache.catalina.core.StandardService.start(StandardService.java:388)
        at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:505)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:776)
        at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
        at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)

I have done some debugging of the ActionServlet class to determine what the 
problem is. Apparently, in your method initApplicationConfig(), you perform the 
following operations:

                          .
                          .
                          .
            URL url = getServletContext().getResource(path);
            InputSource is = new InputSource(url.toExternalForm());
                          .
                          .
                          .

   Apparently, you are attempting to get a "resource" called 
"/WEB-INF/struts-config.xml" (the value of the "path" argument)-- a perfectly 
logical and reasonable way to open the xml file. Unfortunately, despite the fact 
that the xml file is in the appropriate directory, and despite the fact that 
web.xml properly points to that file as specified in your documentation (as the 
snippet below shows), 
                          .
                          .
                          .
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/Web-inf/struts-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
                          .
                          .
                          .

for some reason your call to getServletContext().getResource(path) returns a 
null. This is the cause of the nullPointerException that is in turn causing the 
failure to properly read the struts-config.xml file.

There is no way that a Struts application can work under these circumstances.

Duplicating this problem is not difficult, but you will need my JSP, ActionForm, 
Action, and config files (including web.xml and struts-config.xml). Since your 
bug system does not allow attachment of files, please feel free to contact me if 
you desire these files. Please feel free to contact me if you need any further 
information about this problem. I will post follow- ups to this report if I 
learn anything new concerning it.

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

Reply via email to