?
Solved

Exception when i run my first struts project

Posted on 2005-04-18
18
Medium Priority
?
479 Views
Last Modified: 2013-11-18
hi,
         I am new to struts and i am doing a small project in that. i did the project using netbeans 4.0 and using tomcat 5

when i run the project using tomcat i get many exception i will list the exception and help me to slove the problem

2005-04-14 14:54:48 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrive ActionForward named /firstAction
      at org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:499)
      at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:353)
      at org.apache.jsp.index_jsp._jspx_meth_html_link_0(index_jsp.java:202)
      at org.apache.jsp.index_jsp._jspService(index_jsp.java:81)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
      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)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
      at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
      at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:209)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
      at java.lang.Thread.run(Thread.java:536)


and also i get this exception
java.lang


the struts config file

<form-beans>
<form-bean name="firstForm" type="app.form.FirstForm"/>
</form-beans>

<action-mappings>
<action
       
            path="/firstAction"
           
            type="app.login.FirstAction"
           
            name="firstForm"
           
            input="/index.jsp"/>

    </action-mappings>


i this thing are not enough to solve the problem give me u r mail id i will send the project to u.

thanks,
Pradeep D
0
Comment
Question by:deeppra
  • 9
  • 7
  • 2
18 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 13812539
Hi,

Please post your FirstAction class so that we can look at it.

Regards
Dave
0
 
LVL 5

Author Comment

by:deeppra
ID: 13812868
/*
 * FirstAction.java
 *
 * Created on April 13, 2005, 11:20 PM
 */

package app.login;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;

/**
 *
 * @author Administrator
 */
public class FirstAction extends Action {
   
    public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, javax.servlet.ServletException {
        FirstForm logonform = (FirstForm) form;
        String username = logonform.getUsername();
        String password = logonform.getPassword();
        if(username == null || password == null) {
          return mapping.getInputForward();  
       }
        return mapping.findForward("sucess");
    }

}
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13812951
Hi,

To see the entire things, please post your Form and your JSP file. Sorry for the inconveniences.

Regards
Dave
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:suprapto45
ID: 13812956
Hi,

It is obvious that you miss the forward in your struts-config.xml.

When you call "return mapping.findForward("sucess");", you need to have the appropriate mapping in your struts-config.xml.

However, let me wait for your Form and JSP first.

Regards
Dave
0
 
LVL 5

Author Comment

by:deeppra
ID: 13813022
welcome.jsp

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:form action="/FirstAction">
    Username<html:text property="username" />
    Password<html:password property="password"/>
    <html:submit value="Register"/>
    <html:reset/>
</html:form>

i have already  mapped the forward in the struts-config file

<global-forwards>
<forward
                name="sucess"
                path="/sucesspage.html"/>
       

</global-forwards>



0
 
LVL 5

Author Comment

by:deeppra
ID: 13813035
some times i also get this exception

java.lang.UnsupportedClassVersionError
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13813075
Hi,

let me check that :).

Regards
Dave
0
 
LVL 5

Author Comment

by:deeppra
ID: 13813094
ok fine if u need the source of the project i will mail all the things
if u  wish plz give u r mail ID
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13813139
Hi,

it is okay. Well basically, everything runs fine. I have just tested it on my machine and it runs well. Let me ask you several questions.

1. Do you use any IDE? (Eclipse or what)
2. Have you included all *.jar of Struts to your WEB-INF/lib?

The complete struts-config.xml look like this.

-------------------------------------------------
<?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 Source Configuration =============================== -->
    <data-sources />
   
    <!-- ========== Form Bean Definitions ================================== -->
    <form-beans>
        <form-bean name="TestForm" type="com.global.test.struts.form.TestForm">
            <form-property name="name" type="java.lang.String" />
        </form-bean>        
       
        <form-bean name="firstForm" type="com.global.test.struts.form.FirstForm"/>
       
    </form-beans>
   
    <!-- ========== Global Exception Definitions ============================== -->
    <global-exceptions />
   
    <!-- ========== Global Forward Definitions =============================== -->
    <global-forwards>
      <forward name="sucess" path="/jsp/error.jsp"/>
      </global-forwards>
   
    <!-- ========== Action Mapping Definitions =============================== -->
    <action-mappings>
        <action path="/test"
                    type="com.global.test.struts.action.TestAction"
                    name="TestForm"
                    scope="request"
                    validate="true"
                    parameter="action"
                        input="/jsp/index.jsp"
        >
        <forward name="SaveToDB" path="/jsp/congrats.jsp" />
        <forward name="DispatchRun" path="/jsp/dispatch.jsp" />
       
        </action>
       
            <action path="/firstAction"
         type="com.global.test.struts.action.FirstAction"
         name="firstForm"
         input="/welcome.jsp" > 
         </action>      
    </action-mappings>
   
    <!-- ========== Controller Configuration ================================ -->
    <controller />
   
    <!-- ========== Message Resources Definitions ============================ -->
    <!-- It means that the application.properties is located in the com.global -->
    <message-resources parameter="com.global.application" />
       
    <!-- ========== Plug Ins Configuration ================================= -->
</struts-config>


--------------------------------------------

Regards
Dave
0
 
LVL 5

Author Comment

by:deeppra
ID: 13813185
i will give u my the struts file tell me is there any mistake

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">



<!--

     This is a blank Struts configuration file with an example

     welcome action/page and other commented sample elements.



     Tiles and the Struts Validator are configured using the factory defaults

     and are ready-to-use.



     NOTE: If you have a generator tool to create the corresponding Java classes

     for you, you could include the details in the "form-bean" declarations.

     Otherwise, you would only define the "form-bean" element itself, with the

     corresponding "name" and "type" attributes, as shown here.

-->





<struts-config>



<!-- ==================================== Data Source Configuration -->

<!--

 <data-sources>


 </data-sources>

-->



<!-- ======================================== Form Bean Definitions -->



    <form-beans>
   
       
    <form-bean name="firstForm" type="app.form.FirstForm"/>
    </form-beans>





<!-- ================================= Global Exception Definitions -->



    <global-exceptions>

    </global-exceptions>





<!-- =================================== Global Forward Definitions -->



    <global-forwards>

        <!-- Default forward to "Welcome" action -->

        <!-- Demonstrates using index.jsp to forward -->

     
        <forward
                name="sucess"
                path="/sucesspage.html"/>
       

    </global-forwards>





<!-- =================================== Action Mapping Definitions -->



    <action-mappings>
       
           
        <action
       
            path="/firstAction"
           
            type="app.login.FirstAction"
           
            name="firstForm"
           
            input="/index.jsp"/>
       

   </action-mappings>





<!-- ===================================== Controller Configuration -->



    <controller

       processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>





<!-- ================================ Message Resources Definitions -->



    <message-resources parameter="app.resource.application"/>





<!-- ======================================= Plug Ins Configuration -->


  <!-- ========== Tiles plugin ===================  -->
  <!--                                                                        -->
  <!--
     This plugin initialize Tiles definition factory. This later can takes some
       parameters explained here after. The plugin first read parameters from web.xml, then
       overload them with parameters defined here. All parameters are optional.
       The plugin should be declared in each struts-config file.
       - definitions-config: (optional)
            Specify configuration file names. There can be several comma
                separated file names (default: ?? )
       - moduleAware: (optional - struts1.1)
            Specify if the Tiles definition factory is module aware. If true (default),
                  there will be one factory for each Struts module.
                  If false, there will be one common factory for all module. In this later case,
                  it is still needed to declare one plugin per module. The factory will be
                  initialized with parameters found in the first initialized plugin (generally the
                  one associated with the default module).
                    true : One factory per module. (default)
                    false : one single shared factory for all modules
         - definitions-parser-validate: (optional)
              Specify if xml parser should validate the Tiles configuration file.
                    true : validate. DTD should be specified in file header. (default)
                    false : no validation
                    
        Paths found in Tiles definitions are relative to the main context.
  -->
  <!-- comment following if struts1.0.x -->
  <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <set-property property="definitions-config"
                       value="/WEB-INF/tiles-defs.xml" />
    <set-property property="moduleAware" value="true" />
    <set-property property="definitions-parser-validate" value="true" />
  </plug-in>

  <!-- end comment if struts1.0.x -->

  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property
        property="pathnames"
        value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
  </plug-in>

</struts-config>

0
 
LVL 5

Author Comment

by:deeppra
ID: 13813201
i need to learn struts, i am doing B.tech IT
tell me any free tutorial available for download
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13813206
Hi,

It seems okay just ensure that you have WEB-INF/tiles-defs.xml, /WEB-INF/validator-rules.xml,/WEB-INF/validation.xml in the correct path.

Please let me know your latest error.

Regards
Dave
0
 
LVL 5

Author Comment

by:deeppra
ID: 13813258
i had done the project at home, now i am in the library.
ok i will try and send u the result
can u give u r mail id so that i can have a stright contact
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13813278
Hi,

Sure, davidayudhahalim@yahoo.com.

Regards
Dave
0
 
LVL 5

Author Comment

by:deeppra
ID: 13813388
do u have any study material for struts any e-material or if u know any free tutorials to download
plz send any materials
mail id : pradeep_genius_in@yahoo.com
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 200 total points
ID: 13813464
Your mistake is in your JSP

<html:form action="/FirstAction">
should be
<html:form action="/FirstAction.do">

Also,
java.lang.UnsupportedClassVersionError
comes from compiling using a higher version JDK than the one you are trying to run, e.g. compiling in 1.5 and running in 1.4.2, that's all.
0
 
LVL 5

Author Comment

by:deeppra
ID: 13813522
ok fine i will try in my home and see u later
if i have any problem in struts u r my Master i will send u mail regarding that  ok
if u have any ematerials plz send it to me , this will help me to learn .
And also i have to know about u r personal information
u r name,age,country etc
plz mail me to this mail id :pradeep_genius_in@yahoo.com
i am indian,Male,20 years old doing my B.Tech IT

Thanks
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13813689
http://javaboutique.internet.com/tutorials/Struts/
http://www.coreservlets.com/Apache-Struts-Tutorial/

I only accept emails regarding questions on EE. All other emails will be deleted without being read. Sorry but that's the way it has to be.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
How does storytelling impact the web? What goes into a great story on the web? And how can it be used for marketing purposes? All of these questions will be answered.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question