Sunday, January 18, 2009

Struts Exceptions during development

javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.struts.action.ActionServlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)

root cause
java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)

To avoid these type of exceptions/erros place all the struts related jar files in the lib folder of your web application.

Saturday, January 17, 2009

Using Struts 1.x without tld files

These are the "tag library descriptor" files that describe the custom tags in the various Struts tag libraries. The tld file for any Struts taglibs that you use should be copied into the WEB-INF directory of your web application. (Applications under Servlet 2.3 containers can omit this step if the standard uri is referenced.)

That can be achieved as follows.
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>


For Servlet 2.3/2.4 containers only: The Servlet 2.3 and 2.4 specifications simplify the deployment and configuration of tag libraries. The instructions above will work on older containers as well as 2.3 and 2.4 containers (Struts only requires a servlet 2.2 container); however, if you're using a 2.3/2.4 container such as Tomcat 4.x/5.x, you can take advantage of a simplified deployment.
All that's required to install the Struts tag libraries is to copy struts.jar into your /WEB-INF/lib directory and reference the tags in your code like this:


Note that you must use the full uri defined in the various tlds so that the container knows where to find the tag's class files. You don't have to alter your web.xml file or copy tlds into any application directories.

Friday, January 16, 2009

ClassNotFoundException Dispatcher Servlet in SpringMVC

Some times we may get ClassNotFoundException- Dispatcher Servlet in Spring MVC , even though we keep the spring.jar and spring-webmvc.jar using configuring the build path. The root cause of this error is your IDE expects the jars to be located physically in the lib folder. So Copy all the required jars in the lib folder, that should solve the problem.