1 Reply Latest reply: Oct 11, 2010 7:34 AM by 804447 RSS

    ERROR while devevloping a struts application

    804447
      I am new to struts and trying to develop a simplem applicationusing struts,during which i am gettin an expextion of this sort.I have already placed both struts-core 2.2.1 and xcore 2.2.1 in WEB-INF/lib folder.please help
      SEVERE: Exception starting filter struts2
      java.lang.NoClassDefFoundError: org/apache/struts/action/Action
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClass(Unknown Source)
           at java.security.SecureClassLoader.defineClass(Unknown Source)
           at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1960)
           at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:933)
           at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1405)
           at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
           at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:149)
           at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107)
           at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:410)
           at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365)
           at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:479)
           at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
           at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
           at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
           at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
           at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
           at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
           at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
           at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
           at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
           at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
           at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3666)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4258)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
           at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:980)
           at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:943)
           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
           at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1203)
           at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
           at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
           at org.apache.catalina.core.StandardService.start(StandardService.java:448)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
        • 1. Re: ERROR while devevloping a struts application
          804447
          I was able to rectify that error by placing the struts-core-1.3.10.jarinto the WEB-INf/lib folder.
          But now i am gettin an exception durin the run time
          java.lang.NoSuchMethodException: manipulation.AdditionAction.execute()
               java.lang.Class.getMethod(Unknown Source)
               org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
               org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)
               com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
               com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
               com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
               com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
               com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
               org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
               org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
               org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
          my jsp pages are:
          addition.jsp:

          <%@taglib uri="/struts-tags" prefix="html" %>
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <title>Sample Application</title>

          </head>
          <body>

          <html:form action="Add">

          <html:textfield name="number1" label="Number1" />

          <html:textfield name="number2" label="Number2" />

          <html:submit value="Add" />

          </html:form>
          </body>
          </html>
          success.jsp:
          <html>
          <head>
          <title>Sample Struts Display Name</title>
          </head>
          <body>
          <table width="80%" border="0">
          <tr>
          <td>Addition: <%= request.getAttribute("sum") %> !!</td>
          </tr>
          </table>
          </body>
          </html>
          struts-config.xml:
          <?xml version="1.0" encoding="UTF-8" ?>

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


          <struts-config>
          <form-beans>
          <form-bean name="Addform" type="manipulation.Addform"/>

          </form-beans>

          <global-exceptions>

          </global-exceptions>

          <global-forwards>
          <forward name="welcome" path="/Welcome.do"/>
          </global-forwards>

          <action-mappings>
          <action name="Add" class="manipulation.AdditionAction">
          <forward name="success" path="/success.jsp" />
          <forward name="failure" path="/failure.jsp" />

          </action>
          <action path="/Welcome" forward="/welcomeStruts.jsp"/>
          </action-mappings>


          </struts-config>

          Addform.java:
          package manipulation;
          public class Addform extends org.apache.struts.action.ActionForm
          {
               private int number1;
               private int number2;
               private int sum;
               public Addform()
               {
          }public String getSum()
                    {
               return("Result:"+sum);
                    }public void setSum(int no1,int no2)
                    {
               this.number1=no1;
               this.number2=no2;
               sum=no1+no2;
          } public int getnumber1() {
          return number1;
          } public void setNumber1(int number) {
          this.number1 = number;
          } public int getnumber2 (){
          return number2;
          } public void setNumber2(int number) {
          this.number2= number;
          }
          }
          AdditionAction.java:
          package manipulation;
          import java.io.IOException;
          import javax.servlet.ServletException;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;

          public class AdditionAction extends org.apache.struts.action.Action
          {
               private static final String SUCCESS = "success";
          public ActionForward execute(ActionMapping mapping,ActionForm form,
          HttpServletRequest request, HttpServletResponse response)throws Exception {
               
               int no1=0;
               int no2=0;
          if ( form != null )
          {
          // Use the NameForm to get the request parameters
          Addform formadd = (Addform) form;
          no1 =formadd.getnumber1() ;
          no2=formadd.getnumber2();
          }
          // if no mane supplied Set the target to failure

          request.setAttribute("number1", no1);
          request.setAttribute("number2", no2);
                    return (mapping.findForward(SUCCESS));
          }

          please help...

          }