I think the default being specified as [NONE] means:

- If you *do not* use application messages in your code, and do not use any
Struts tags which use them, then you do not need to specify a value for
'application' in your configuration.

- If you *do* use application messages directly, or use tags which use them,
then there is no default value and you must specify a valid value.

The <struts:errors/> tag needs to look up messages in the properties file,
so you will need to specify a value for 'application' in your configuration
if you want to use that tag.

Hope this helps.

--
Martin Cooper
Tumbleweed Communications

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 24, 2001 1:10 PM
Subject: no 'application' init parameter for ActionServlet causes NullPoin
terException in <struts:errors /> ??


> Hello!  I'm just beginning to use struts, and I enjoy it very much.  Thank
> you to all who have contributed to it.  I have encountered a problem and
> would like to ask about it.  I've searched the archives and couldn't find
> anything on this.
>
> My problem:  When I configure my ActionServlet without specifiying an
> 'application' init parameter, I receive a NullPointerException when I use
> the <struts:errors /> tag in my  jsp page.  Has anyone else seen this?
>
> The javadoc states the following:
> The initialization parameters supported by the controller servlet are
> described below, which is copied from the Javadocs for the ActionServlet
> class. Square brackets describe the default values that are assumed if you
> do not provide a value for that initialization parameter.
>
> application - Java class name of the application resources bundle base
> class. [NONE]
> bufferSize - The size of the input buffer used when processing file
uploads.
> [4096]
> config - Context-relative path to the XML resource containing our
> configuration information. [/WEB-INF/struts-config.xml]
> ...
>
> so, it appears to me that if I don't specify an application parameter, I
> should be okay.  However, I receive the following error:
>
> java.lang.NullPointerException at
> org.apache.struts.taglib.ErrorsTag.doStartTag(ErrorsTag.java:201)
> at
>
_0002flogon_0002ejsplogon_jsp_5._jspService(_0002flogon_0002ejsplogon_jsp_5.
> java:89)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:177)
> at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:382)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)
> at org.apache.tomcat.core.Handler.service(Handler.java:263)
> at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)
> at
>
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
> .java:191)
> at
>
org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.ja
> va:1589)
> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1432)
> at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:481)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)
> at org.apache.tomcat.core.Handler.service(Handler.java:263)
> at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)
> at
>
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:74
> 9)
> at org.apache.tomcat.core.ContextManager.service(ContextManager.java:695)
> at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java:207)
> at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:403)
>
> at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
> at java.lang.Thread.run(Thread.java:484)
>
>
> This is my jsp page:
> <%@ page errorPage="error.jsp" %>
> <%@ taglib uri="/WEB-INF/struts.tld" prefix="struts" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>
> <html:html locale="true">
>
>
> <head>
> <!-- BEGIN SCRIPT //-->
> <script language="JavaScript">
> <!--
> function doInit() { document.login_form.username.focus(); }
> //-->
> </script>
> <!-- END SCRIPT //-->
>
>
> <link REL="stylesheet" HREF="/asmt/asmt.css" TYPE="text/css">
> <title>ASMT Library Login</title>
> </head>
>
>
>
> <body onload="doInit()">
>
> <struts:errors />
>
> <div align="center"><center>
>
> <html:form name="login_form" action="logon.do">
> <div align="center"><center>
> <table border="0" cellpadding="0" cellspacing="0"
> width="423">
> <tr align="center">
> <td width="423" colspan="3">
> <center>
> <h2>ASMT Library System</h2>
> <h3>Welcome.&nbsp; Please Log In.</h3>
> </td>
> </tr>
>
> <tr align="center">
>       <td width="107">
> <div align="left"><p>Username
> </td>
>       <td width="209" align="left">
> <div align="left"><p>
> <html:text property="username" size="20"
> tabindex="1"/>
> </td>
>       <td width="107" align="left">
> <html:submit value="Logon" style="width:
> 80px" tabindex="4" />
> </td>
> </tr>
>
> <tr align="center">
> <td width="107">
> <div align="left"><p>Password
> </td>
> <td width="209" align="left">
> <html:password property="password" size="20"
> tabindex="2" />
> </td>
> <td width="107" align="left">
> <html:reset style="width: 80px" tabindex="5"
> />
> </td>
> </tr>
>
> </table>
>   </center></div>
> </html:form>
>
> </body>
> </html:html>
>
>
> Prehaps there's something I'm should be doing in my page that I'm not?
I've
> looked at the source code, and the error is because the 'messages' object
is
> null.  It is assigned a few lines above in the following statement:
> MessageResources messages = (MessageResources)
>   pageContext.getAttribute(Action.MESSAGES_KEY,
>    PageContext.APPLICATION_SCOPE);
>
> That's all I know to trace, since I'm new to the code.  If I remove the
> <struts:errors /> tag, the code works fine.  I copied the
> ApplicationResource.properties file, placed it in my classes directory,
and
> add the application init parameter and again everything works fine.  Have
I
> done something wrong, is this a bug, or is should the application
parameter
> be required for correct operation?
>
> Just for completeness, below is my web.xml file and struts-config.xml
file.
> My apologies if this is too verbose for some.
>
> Thanks for your help,
> Perry Tew
>
> Tomcat 3.2
> NT4.0 workstation
> JDK1.3
>
>
____________________________________________________________________________
> ___________
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>     "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> <web-app>
> <servlet>
> <servlet-name>libServlet</servlet-name>
> <servlet-class>ASMTLibraryServlet</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>libServlet</servlet-name>
> <url-pattern>/library/*</url-pattern>
> </servlet-mapping>
>
> <!-- Action Servlet Configuration -->
>   <servlet>
>     <servlet-name>action</servlet-name>
>     <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> <!--
>     <init-param>
>       <param-name>application</param-name>
>       <param-value>ApplicationResources</param-value>
>     </init-param>
> -->
>     <init-param>
>       <param-name>config</param-name>
>       <param-value>/WEB-INF/struts-config.xml</param-value>
>     </init-param>
>     <init-param>
>       <param-name>debug</param-name>
>       <param-value>2</param-value>
>     </init-param>
>     <init-param>
>       <param-name>detail</param-name>
>       <param-value>2</param-value>
>     </init-param>
>     <init-param>
>       <param-name>validate</param-name>
>       <param-value>true</param-value>
>     </init-param>
>     <load-on-startup>2</load-on-startup>
>   </servlet>
>
>   <!-- Action Servlet Mapping -->
>   <servlet-mapping>
>     <servlet-name>action</servlet-name>
>     <url-pattern>*.do</url-pattern>
>   </servlet-mapping>
>
>
>   <!-- Struts Tag Library Descriptors -->
>   <taglib>
>     <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
>     <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
>   </taglib>
>
>   <taglib>
>     <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
>     <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
>   </taglib>
>
>   <taglib>
>     <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
>     <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
>   </taglib>
>
> </web-app>
>
>
____________________________________________________________________________
> ___
> <?xml version="1.0" encoding="ISO-8859-1" ?>
>
> <!DOCTYPE struts-config PUBLIC
>           "-//Apache Software Foundation//DTD Struts Configuration
1.0//EN"
>           "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
>
> <struts-config>
>   <form-beans>
>     <!-- Logon form bean -->
>     <form-bean      name="logonForm"
>                     type="LogonForm"/>
>   </form-beans>
>   <global-forwards>
>     <forward   name="logon"                path="/logon.jsp"/>
>     <forward   name="success"              path="/main.jsp"/>
> <forward   name="failure"              path="/failedLogin.html" />
>   </global-forwards>
>
>
>   <action-mappings>
>     <!-- Process a user logon -->
>     <action    path="/logon"
>                type="LogonAction"
>                name="logonForm"
>               scope="request"
>               input="/logon.jsp"
>   unknown="true"
> >
>     </action>
>   </action-mappings>
> </struts-config>
>


Reply via email to