Note that there are some explanatory texts on larger screens.

plurals
  1. POClassCastException for Filter in Tomcat startup
    text
    copied!<p>Im getting an error like this. This is happend when i run the program and it did not run.it showed following error.</p> <pre><code>Jul 10, 2013 1:21:24 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Kaspersky Lab\Kaspersky Anti-Virus 6.0 for Windows Workstations MP4\;C:\Program Files\Java\jdk1.6.0_07/bin;C:\Program Files\MySQL\MySQL Server 5.2\bin;D:\common libs\com.mysql.jdbc_5.1.5.jar;;C:\Users\lcladmin\Documents\Softwares\java related\eclipse-jee-indigo-win32_2\eclipse; Jul 10, 2013 1:21:24 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:BankDemoWeb' did not find a matching property. Jul 10, 2013 1:21:24 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Jul 10, 2013 1:21:24 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Jul 10, 2013 1:21:24 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 552 ms Jul 10, 2013 1:21:24 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Jul 10, 2013 1:21:24 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.41 Jul 10, 2013 1:21:25 PM org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter FilterRequest java.lang.ClassCastException: com.mobitel.bankdemo.web.FilterRequest cannot be cast to javax.servlet.Filter at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:107) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4746) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5399) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Jul 10, 2013 1:21:25 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error filterStart Jul 10, 2013 1:21:25 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/BankDemoWeb] startup failed due to previous errors Jul 10, 2013 1:21:25 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Jul 10, 2013 1:21:25 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Jul 10, 2013 1:21:25 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 533 ms </code></pre> <p>Can any one tell me the reason of getting this error? (Im doing a web java application using jsp,servlet,tomcat.)</p> <p>Here my FilterRequest.java file code</p> <pre><code>package com.mobitel.bankdemo.web; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer; import java.util.logging.Filter; import java.util.logging.LogRecord; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.mobitel.bankdemo.domain.User; public class FilterRequest implements Filter{ private static final long serialVersionUID = 1L; FilterConfig filterConfig = null; public FilterRequest() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; } public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; HttpSession session = request.getSession(true); User u = (User) session.getAttribute("loggedUser"); System.out.println(u+"i"); if (u!= null) { System.out.println(u+"u"); chain.doFilter(req, resp); return; }else{ String message = "Please Login!"; req.setAttribute("loginMsg", message); response.sendRedirect("login2.jsp"); } } public void destroy() { // do cleanup stuff } @Override public boolean isLoggable(LogRecord arg0) { // TODO Auto-generated method stub return false; } } </code></pre> <p>web.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt; &lt;display-name&gt;BankDemoWeb&lt;/display-name&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;home.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;servlet&gt; &lt;servlet-name&gt;AccountController&lt;/servlet-name&gt; &lt;servlet-class&gt;com.mobitel.bankdemo.web.AccountControllerServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;AccountController&lt;/servlet-name&gt; &lt;url-pattern&gt;/account&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;session-config&gt; &lt;session-timeout&gt;5&lt;/session-timeout&gt; &lt;/session-config&gt; &lt;filter&gt; &lt;filter-name&gt;FilterRequest&lt;/filter-name&gt; &lt;filter-class&gt;com.mobitel.bankdemo.web.FilterRequest&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;FilterRequest&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload