You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gregg Williams <gr...@pubspace.com> on 2004/02/10 19:35:09 UTC

Beginner question: form bean executing but action class not

Hi,

I have gotten my first extremely simple (2 web pages) Struts application 
working and am slowly adding features to it. In first page, you enter data 
into a form and click the submit button. This takes you to the second page, 
which displays the data from the form; and clicking the submit button on 
this page takes you back to the first page--very simple.

My problem is that for the first page (entryPage.jsp), its form bean, 
EntryForm.java seems to be executing, but the corresponding action class, 
EntryAction.java does not. I have checked two very good books and have 
checked my code against sample code, but i can't figure out what's different.

Below, I've listed the struts-config.xml and EntryAction.java files. I know 
I must be overlooking something incredibly simple. Thanks for your help.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts 
Configuration 1.1//EN"
                                "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
     <data-sources/>
     <form-beans>
         <form-bean name="entryForm" type="sample.EntryForm"/>
         <form-bean name="displayForm" type="sample.DisplayForm"/>
     </form-beans>
     <global-exceptions/>
     <global-forwards>
         <forward name="begin" path="/Display.do"/>
     </global-forwards>
     <action-mappings>
         <action name="entryForm" path="/Entry" scope="request" 
type="sample.EntryAction">
             <forward name="displayPage" path="/pages/displayPage.jsp"/>
         </action>
         <action name="displayForm" path="/Display" scope="request" 
type="sample.DisplayAction">
             <forward name="entryPage" path="/pages/entryPage.jsp"/>
         </action>
     </action-mappings>
     <controller/>
</struts-config>

package sample;

import java.io.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.util.MessageResources;

public class EntryAction extends org.apache.struts.action.Action {

     // Global Forwards
     public static final String GLOBAL_FORWARD_begin = "begin";

     // Local Forwards
     private static final String FORWARD_displayPage = "displayPage";

     public EntryAction() {
         System.out.println ("EntryAction: Reached constructor method");
     }

     public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws Exception {
         // TODO: Write method body
         return mapping.findForward(FORWARD_displayPage);
     }
}

***** end *****



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Struts 1.1 on Tomcat 5.0.18?

Posted by Steve Hill <st...@finelineco.com>.
I had sent a previous message to this list with a complete error listing,
but I'll clarify. I downloaded and installed a new installation of Tomcat
5.0.18. I then downloaded and installed a new installation of struts 1.1,
copying the documentation and example application war files into Tomcat's
Webapps directory, and restarting Tomcat.

Running the http://localhost:808/struts-documentation works fine. Running
http://localhost:808/struts-example gives the following error message. I
followed the other instructions (XML parser, JDBC2, xalan-j) as specified in
v1.16 of the Struts readme file. The exception report I get when running
struts-example is:

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
 at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:5
58)
 at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
91)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.IllegalStateException: zip file closed
 at java.util.zip.ZipFile.getEntry(ZipFile.java:141)
 at java.util.jar.JarFile.getEntry(JarFile.java:181)
 at sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:76)
 at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:96)
 at
sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.ja
va:108)
 at java.net.URL.openStream(URL.java:798)
 at
org.apache.catalina.loader.StandardClassLoader.getResourceAsStream(StandardC
lassLoader.java:714)
 at
org.apache.catalina.loader.StandardClassLoader.getResourceAsStream(StandardC
lassLoader.java:696)
 at
org.apache.catalina.loader.WebappClassLoader.getResourceAsStream(WebappClass
Loader.java:1202)
 at javax.xml.parsers.SecuritySupport12$4.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at javax.xml.parsers.SecuritySupport12.getResourceAsStream(Unknown Source)
 at javax.xml.parsers.FactoryFinder.findJarServiceProvider(Unknown Source)
 at javax.xml.parsers.FactoryFinder.find(Unknown Source)
 at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
 at
org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:12
9)
 at
org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:112)
 at org.apache.jasper.compiler.JspConfig.init(JspConfig.java:213)
 at org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:229)
 at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:201)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
 at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:5
52)
 at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
91)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

Specific suggestions welcome, else I will just start over if Struts 1.1 is
normally known to work successfully on Tomcat 5.0.18. It looks like
something is missing but if the Struts readme docs are correct it should
work. This particular error is a known Sun issue in a previous Tomcat
version. Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Struts 1.1 on Tomcat 5.0.18?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 02/10/2004 07:38 PM Steve Hill wrote:
> Is anyone here successfully using Struts 1.1 on Tomcat 5.0.18? I am getting
> "java.lang.IllegalStateException: zip file closed errors" with any
> struts-using code and am wondering if this is a bug and I should go back to
> an earlier version of one or the other. Thanks.

Yes, probably hundreds of people. When do you get that error? Without 
more details it's impossible to say what you need to do.

Adam
-- 
struts 1.1 + tomcat 5.0.16 + java 1.4.2
Linux 2.4.20 Debian


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Struts 1.1 on Tomcat 5.0.18?

Posted by Steve Hill <st...@finelineco.com>.
Is anyone here successfully using Struts 1.1 on Tomcat 5.0.18? I am getting
"java.lang.IllegalStateException: zip file closed errors" with any
struts-using code and am wondering if this is a bug and I should go back to
an earlier version of one or the other. Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org