1

I'm trying to create a struts2 application. I've set up the spring, struts and web xml files. When I leave out the filter "StrutsPrepareAndExecuteFilter", it deploys to the tomcat server, but when I go to a jsp, with any type of struts tag in it, I get the following error.

Here is the stack trace:

Servlet.service() for servlet [jsp] in context with path [] threw exception [An exception occurred processing JSP page /index.jsp at line 259 Stacktrace:] with root cause The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location] at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60) at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48) at org.apache.jsp.index_jsp._jspx_meth_s_005furl_005f0(index_jsp.java:638) at org.apache.jsp.index_jsp._jspService(index_jsp.java:320) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run 

Then when I put the filter back in my web.xml file, the server doesn't even deploy. When I restart the server with the filter, I get this:

Connected to server [2015-07-29 07:55:21,077] Artifact Admin:war exploded: Artifact is being deployed, please wait... log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Jul 29, 2015 7:55:27 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error filterStart Jul 29, 2015 7:55:27 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [] startup failed due to previous errors Jul 29, 2015 7:55:27 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. [2015-07-29 07:55:27,837] Artifact Admin:war exploded: Error during artifact deployment. See server log for details. Jul 29, 2015 7:55:30 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /java/apache-tomcat-7.0.47/webapps/manager Jul 29, 2015 7:55:31 PM org.apache.catalina.loader.WebappClassLoader loadClass INFO: Illegal access: this web application instance has been stopped already. Could not load org.apache.tomcat.jdbc.pool.FairBlockingQueue$FairIterator. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact. java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1588) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) at org.apache.tomcat.jdbc.pool.FairBlockingQueue.iterator(FairBlockingQueue.java:233) at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:989) at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:981) at org.apache.tomcat.jdbc.pool.ConnectionPool$PoolCleaner.run(ConnectionPool.java:1348) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Exception in thread "PoolCleaner[2142566374:1438221326908]" java.lang.NoClassDefFoundError: org/apache/tomcat/jdbc/pool/FairBlockingQueue$FairIterator at org.apache.tomcat.jdbc.pool.FairBlockingQueue.iterator(FairBlockingQueue.java:233) at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:989) at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:981) at org.apache.tomcat.jdbc.pool.ConnectionPool$PoolCleaner.run(ConnectionPool.java:1348) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.FairBlockingQueue$FairIterator at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) ... 6 more 

Here is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!--Spring Configuration --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring.xml,</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>com.howe.listener.InitContextListener</listener-class> </listener> <filter> <filter-name>xssFilter</filter-name> <filter-class>com.howe.Filter.XssFilter</filter-class> </filter> <filter-mapping> <filter-name>xssFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>xssFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>actionPackages</param-name> <param-value>com.howe.Action</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>400</error-code> <location>/error.jsp</location> </error-page> <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/error.jsp</location> </error-page> <error-page> <error-code>503</error-code> <location>/error.jsp</location> </error-page> <error-page> <error-code>504</error-code> <location>/error.jsp</location> </error-page> <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/error.jsp</location> </error-page> </web-app> 

Could someone plase help me? Could it be the versions of the jars in my project?

Here's my lib folder:

HERE IS PART OF MY LIB FOLDER

PART 2 OF MY LIB FOLDER

PART 3 OF MY LIB FOLDER

6
  • Show your web.xml and your lib folder Commented Jul 30, 2015 at 2:30
  • I have added what you requested Commented Jul 30, 2015 at 4:54
  • 1
    Did you try hiding XSSFilter configuration in web.xml ? Commented Jul 30, 2015 at 6:04
  • A lot of libraries are not from Struts. If you are using Struts and have problems with it make sure you have all required dependencies. Don't copy server libraries to the application, instead use runtime scope for the server dependencies. Commented Jul 30, 2015 at 8:16
  • 1
    Please post text, not images. Commented Jul 30, 2015 at 19:53

2 Answers 2

0

As said in this answer, Tomcat JDBC pool has been introduced in Tomcat 7.0.19.

Since you've not specified which Tomcat version you're using, then

  • if Tomcat < 7.0.19: you need to put the tomcat-jdbc.jar in Tomcat shared /lib folder, not in your ear/war lib folder like you are doing;

  • if Tomcat >= 7.0.19, the jar is already on the server, and you are getting the NoClassDefFoundError because you are putting it in the ear/war and Tomcat doesn't know which one to pick (between the server one and the package one).

In both cases, you need to remove it from your package.

In Maven you do it by adding <scope>provided</scope> to your dependencies already on the server.

Sign up to request clarification or add additional context in comments.

1 Comment

Also remember to paste code (not images) in your questions, and consider upgrading to 2.3.24 instead of staying with 2.3.16.2. Newer is better.
0

Babel was right.... The xssFilter had some dependencies that I forgot to add, and on startup when the constructor ran it couldn't create the class. The logs were a little misleading but I figured it out! Thanks guys

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.