Implenting javax.servlet.Filter issue in Eclipse
I received a java class from my team, and am trying to compile it in Eclipse. However, its complaining that I need to define getFilterConfig() and setFilterConfig().
I mean, I can easily implement those methods, but the odd thing is, my teamates have been able to compile it fine without those two methods.
Any ideas why this is happening?
To implement a javax.servlet.Filter all you need to override are just the three methods mentioned in the Filter API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/Filter.html].
Is it actually a javax.servlet.Filter which you're implementing? Check the implements clause of your class.
Similar Messages
-
Weblogic.utils.NestedRuntimeException when using javax.servlet.Filter
IDE: JDev 10gR3.4 & JDev 11gR2.3
ViewController technology: JSF/ADF Faces
Example code flow:
Run page2.jsf
MyFilter intercepts request, checks for parameter on session.
If parameter not null, goto page2.jsf
Else redirect to page1.jsf
page1.jsf has a button that sets the value on the session scope after clicking.
In jdev 11gR2.3, I get an weblogic.utils.NestedRuntimeException after clicking the button on page1.jsf. This error does not occur in jdev 10gR3.5. Although the application continues to execute and proper info is displayed, I’m wondering why this occurs and also if I should be concerned. Has anyone experienced a similar issue when using javax.servlet.Filter in 11g?
MyFilter code snipet:
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
try {
HttpServletRequest httpRequest = (HttpServletRequest)servletRequest;
HttpServletResponse httpResponse = (HttpServletResponse)servletResponse;
String redirect = httpRequest.getContextPath() + "/faces/page1.jsf"; //only difference here is 11g uses jsf, 10g uses jsp.
String uri = httpRequest.getRequestURI().toString();
Boolean mySessionAttribute = (Boolean)httpRequest.getSession().getAttribute("MYSESSIONATTRIBUTE");
if (uri.endsWith(redirect) || mySessionAttribute != null) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
httpResponse.sendRedirect(redirect);
return;
} catch (IOException e) {
e.printStackTrace();
} catch (ServletException e) {
e.printStackTrace();
page1.jsf/jsp
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<h:form id="f1">
<h:commandButton value="Submit" id="cb1" action="#{Page1Bean.clicked}" type="submit"/>
</h:form>
</f:view>page2.jsf/jsp
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="main.jsf" id="d1">
<af:form id="f1">
<af:outputText value="This is the main content" id="ot1"/>
</af:form>
</af:document>
</f:view>Page1Bean.java
public class Page1Bean {
public void clicked() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
externalContext.getSessionMap().put("MYSESSIONATTRIBUTE", Boolean.TRUE);
try {
externalContext.redirect("/11gFilterExample-ViewController-context-root/faces/page2.jsf");
} catch (IOException e) {
e.printStackTrace();
}Full exception
weblogic.utils.NestedRuntimeException: Cannot parse POST parameters of request: '/11gFilterExample-ViewController-context-root/faces/page1.jsf'
at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:2144)
at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.parseQueryParams(ServletRequestImpl.java:2024)
at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.getQueryParams(ServletRequestImpl.java:1918)
at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.getParameter(ServletRequestImpl.java:1995)
at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.access$800(ServletRequestImpl.java:1817)
at weblogic.servlet.internal.ServletRequestImpl.getParameter(ServletRequestImpl.java:804)
at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:169)
at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:43)
at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:31)
at org.apache.myfaces.trinidadinternal.context.external.AbstractAttributeMap.get(AbstractAttributeMap.java:73)
at oracle.adfinternal.controller.state.ControllerState.getRootViewPortFromRequest(ControllerState.java:788)
at oracle.adfinternal.controller.state.AdfcContext.initialize(AdfcContext.java:185)
at oracle.adfinternal.controller.state.AdfcContext.initialize(AdfcContext.java:79)
at oracle.adfinternal.controller.application.AdfcConfigurator.beginRequest(AdfcConfigurator.java:53)
at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._startConfiguratorServiceRequest(GlobalConfiguratorImpl.java:562)
at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl.beginRequest(GlobalConfiguratorImpl.java:212)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:174)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:177)
at weblogic.servlet.internal.ServletInputStreamImpl.read(ServletInputStreamImpl.java:228)
at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:2118)
... 39 more
<UIXEditableValue> <_isBeanValidationAvailable> A Bean Validation provider is not present, therefore bean validation is disabledI dont believe that solution pertains to my case. clicked() is invoked from standard jsf page and the adf controller is not acquired yet. i put a couple of print statements in the filter and it seems that the doFilter is called twice! This is not the case when running in 10g.
if (uri.endsWith(redirect) || mySessionAttribute != null) {
System.out.println("URI dofilter: "+uri);
filterChain.doFilter(servletRequest, servletResponse);
} else {
System.out.println("URI sendRedirect: "+uri);
httpResponse.sendRedirect(redirect);
}11g weblogic console log:
URI sendRedirect: /11gFilterExample-ViewController-context-root/faces/page2
URI dofilter: /11gFilterExample-ViewController-context-root/faces/page1.jsf
URI dofilter: /11gFilterExample-ViewController-context-root/faces/page1.jsf
10g oc4j console log:
13/01/07 15:48:13 URI sendRedirect: /10gFilterExample-ViewController-context-root/faces/page2.jsp
13/01/07 15:48:13 URI dofilter: /10gFilterExample-ViewController-context-root/faces/page1.jsp
I believe whatever thats causing this occur could be why the exception is thrown... -
Weblogic 7.0 and 6.1 javax.servlet.filter implementation
Hi All,
I was using weblogic 6.1 and as my organization wants to go for 7.0, we
are in the process of evaluating 7.0 ver.
WL6.1 javax.servlet.filter interface provides the methods doFilter(), setFilterConfig(),
getFilterConfig(). We have an implementation for the Filter which also contains
a private method init(FilterCongig filterConfig).
In 7.0 javax.servlet.filter interface the methods are doFilter(), init(), destroy().
Because of the obvious reason i have a private implementation of init(FilterConfig
)in my code the build does not succeed. When i checked the java specifications
from Sun site I found 1.3.1 and 1.4(beta) specs provide doFilter(), init() and
destroy().
Question is: Is weblogic 6.1, JDK 1.3.1 compliant, if so why there is not init()
method in the filter interface??. (Otherwise its a bug)
Because of this the porting has become a serious issue as in some cases we need
to support both 6.1 and 7.0
6.1 did not implement the final version of the Servlet 2.3 specification, that's
why you see differences.
http://edocs.bea.com/wls/docs61/notes/new.html#1064420
Sanjeev <[email protected]> wrote:
> Hi All,
> I was using weblogic 6.1 and as my organization wants to go for 7.0, we
> are in the process of evaluating 7.0 ver.
> WL6.1 javax.servlet.filter interface provides the methods doFilter(), setFilterConfig(),
> getFilterConfig(). We have an implementation for the Filter which also contains
> a private method init(FilterCongig filterConfig).
> In 7.0 javax.servlet.filter interface the methods are doFilter(), init(), destroy().
> Because of the obvious reason i have a private implementation of init(FilterConfig
> )in my code the build does not succeed. When i checked the java specifications
> from Sun site I found 1.3.1 and 1.4(beta) specs provide doFilter(), init() and
> destroy().
> Question is: Is weblogic 6.1, JDK 1.3.1 compliant, if so why there is not init()
> method in the filter interface??. (Otherwise its a bug)
> Because of this the porting has become a serious issue as in some cases we need
> to support both 6.1 and 7.0
Dimitri
-
We have defined the web app to use Form based authentication. Some of the images internal to our application we would like to allow access without having to formally log into the system. In order to accomodate this we have created an javax.servlet.Filter where we strip off some parameters off of the end of the url to log them in.
This works great for everything EXCEPT urls that are in <img src> tags. urls in these tags will never hit the filter. You can take the same url and place it in the browser and it will hit the filter. Its just urls in <img src> tags.
The images cannot be moved to a public place, they must stay where they are.
Does anyone know why the <img src> tag is doing this? It is fairly easy to replicate. Just use form based authentication, create a filter, and try to access an image from an img src tag.
Be sure to clear your browser cache and try again if you think you have it working.
Any security gods out there?
Thanks,
MarkSince nobody responded, I will tell you what we decided to do. For images, we use a servlet outside of the security wall that loads and streams an image back to the browser instead of a direct image url.
So we do something like this:
<img src="https:\\foo.com\Servlet\ImageDisplay?id=1234&user=23432">
Then our servlet parses the params, finds and streams back the image, and instead of returning back "html\text" in the servlet, the servlet returns something like this:
HttpServletResponse response = blah...
BufferedImage bi = new BufferedImage("load in the image resource");
try {
response.setContentType("image/gif");
ServletOutputStream out = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(bi);
catch (IOException ioe) {
servlet.log("DrawMapAction: IO Exception encoding JPEG to ServletOutputStream.", ioe);
} -
Hi,
I am using the below filter mapping
<filter-mapping>
<filter-name>jscomments</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>
This Mapping works on my local linux dev box but I deploy it
on our acceptance machines, the Filter does not kick in. I am not
sure if all the static files(like js, html, etc) are being served
by any Webservers like Apache, IIS or if there is any mistake with
my mappings. I do not any Jrun Admin experience.
If any one had any similar issues in the past, please let me
know ASAP of any fix you might have.
Thanks
AlusacYes, I am using 2.4.
The filter that is not involed is defined:
<filter>
<filter-name>Authenticator</filter-name>
<filter-class>com.authentication.Authenticate</filter-class>
</filter>
<filter-mapping>
<filter-name>Authenticator</filter-name>
<servlet-name>UserService</servlet-name>
</filter-mapping>
and the servlet is:
<servlet id="Servlet_1">
<servlet-name>UserService</servlet-name>
<display-name>User Services</display-name>
<servlet-class>com.user.UserServices</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping id="Mapping_1">
<servlet-name>UserService</servlet-name>
<url-pattern>/User</url-pattern>
</servlet-mapping> -
Hi,
In my project we have written custom filter which will intercept each request and check whether session is active or not. If not then redirect it to login page else user can do normal operation.
but the problem is, whenever i make a request, CustomFilter.doFilter() method is getting called 7-8 times. Ideally it should be called once, can anybody tell me what would be the root cause?
following are the configuration made for customfilter in web.xml
<filter>
<filter-name>customfilter</filter-name>
<filter-class>com.foo.CustomFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>customfilter</filter-name>
<url-pattern>*.jfsf</url-pattern>
</filter-mapping>
Apart from this, i do have faces-servlets default filter in web.xml
Am I am missing something in the filter configuration?>
Please advice.
Thanks
chintanI have the same problem, but in my case its looping inside the doFilter and never terminationg from it, and becz of that I dont see the 1st page(Login page ) what could be the problem,
here is my web.xml..
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>
com.indemand.indab.architecture.LoginFilter
</filter-class>
<init-param>
<param-name>error_page</param-name>
<param-value>login.jsp</param-value>
</init-param>
<init-param>
<param-name>login_page</param-name>
<param-value>login.jsp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
and here is filter class----
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpSession session = ((HttpServletRequest) request).getSession(true);
User currentUser = (User) session.getAttribute("user");
String URI = ((HttpServletRequest) request).getRequestURI();
System.out.println("Filter doFilter ......");
if (filterConfig == null) {
System.out.println("filterConfig null.");
return;
if (filterConfig.getInitParameter("error_page") != null) {
errorPage = filterConfig.getInitParameter("error_page");
} else {
errorPage = "/indabch/login.jsp";
if (filterConfig.getInitParameter("login_page") != null) {
loginPage = filterConfig.getInitParameter("login_page");
} else {
loginPage = "/indabch/login.jsp";
if (currentUser == null) {
((HttpServletResponse) response).sendRedirect(loginPage);
} else {
AuthorizationManager loginMan = new LoginManager();
boolean authorized = loginMan.isUserAuthorized(currentUser
.getLoginName(), currentUser.getPassword());
if (authorized) {
chain.doFilter(request, response);
} else {
((HttpServletResponse) response).sendRedirect(errorPage);
} -
i have try to applied multiple jsp page & it runs correctly.
my descriptor is like this:
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<url-pattern>/user/a.jsp</url-pattern>
<url-pattern>/user/b.jsp</url-pattern>
<url-pattern>/user/c.jsp</url-pattern>
</filter-mapping>now i want to add a servlet, but that filter is not executed...
i have tried descriptor like this:
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<url-pattern>/user/a.jsp</url-pattern>
<url-pattern>/user/b.jsp</url-pattern>
<url-pattern>/user/c.jsp</url-pattern>
<servlet-name>dServlet</servlet-name>
</filter-mapping>and like this:
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<url-pattern>/user/a.jsp</url-pattern>
<url-pattern>/user/b.jsp</url-pattern>
<url-pattern>/user/c.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<servlet-name>dServlet</servlet-name>
</filter-mapping>both are not work...
is the descriptor wrong? what is the correct descriptor?
thank you.i forgot about dispatcher type...
the servlet is accessed via FORWARD
& i map the servlet to /WEB-INF/dServlet...
it is wrong? but the servlet is accessible...
<servlet-mapping>
<servlet-name>dServlet</servlet-name>
<url-pattern>/WEB-INF/dServlet</url-pattern>
</servlet-mapping>the web.xml now is:
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<url-pattern>/user/a.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<url-pattern>/user/b.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<url-pattern>/user/c.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AnonymousFilter</filter-name>
<servlet-name>dServlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>i put this inside the filter:
System.out.println(System.out.println("Anonymous Filter > " + httpRequest.getRequestURI());& hopelessly when i access from a.jsp, b.jsp, c.jsp the filter do print in System.out. but not from servlet...
someone please help me... -
Javax.servlet.Filter
I was curious about gzip compression with JSP's and came across Filters in previous threads. I read the Servlet 2.3 specs and would like to implement a Filter on my jsp's. Does anybody have an example of how to do this? I can't find any tutorials.
Thanks,
JEBSorry if that was a dumb post. I searched Sun's site and that page never showed up.
Thanks,
JEB -
Javax.servlet.Filter, throw file not found exception
I want to use a url which is not exists to let the filter run.
In the method doFIlter(), if the URL is this one, I will return and do not run chain.doFilter
Why throw FIle not found exception? Will the fileter check the url whether exist or not?I use the URL to let the filter run, but do not want to go to the URL.What should happen if someone requests the URL from the server ?
Nothing is not possible.
One possibilty is to send the HTTP Response Code 204 - No Content
The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.
If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
(RFC 2616 Fielding, et al.) -
Javax.servlet.ServletException: Servlet execution threw an exception
Hi guys...
I got an error message after I click a button on my page. Before my action class called, servlet throw an exception.
this is the error message from my eclipse console.
15:31:31,062 INFO [STDOUT] javax.servlet.ServletException: Servlet execution threw an exception
15:31:31,062 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
15:31:31,062 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at roll.mov.j2ee.common.filters.PersistFilter.doFilter(PersistenceFilter.java:160)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
15:31:31,156 INFO [STDOUT] at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
15:31:31,156 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
15:31:31,156 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
15:31:31,156 ERROR [PersistFilter] Exception object caught by servlet persist filter.
15:31:31,171 ERROR [[action]] Servlet.service() for servlet action threw exception
roll.mov.j2ee.common.exceptions.RollMovException: Error caught
begin nested exception:
javax.servlet.ServletException: Servlet execution threw an exception
end nested exception:
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at roll.mov.j2ee.common.filters.PersistenceFilter.doFilter(PersistenceFilter.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Note:
- roll.mov.j2ee.common.exceptions.RollMovException is my custom exception.
- roll.mov.j2ee.common.filters.AuthenticationFilter, implement javax.servlet.Filter
- roll.mov.j2ee.common.filters.PersistFilter, implement javax.servlet.Filter
this persistFilter work as proxy hibernate filterFrom my experience, Normally the root cause will be display in the exception. but this error message doesn't provide any information about what's wrong with my code.
Anyone have an idea?
Thanks in advamce
pdtThanks for replying gimbal2.
in that line, " AuthenticationFilter.java:167" i called the
filterChain.doFilter(request, response);where filterChain is object of javax.servlet.FilterChain
I run my jboss with debug mode and i got abit more information about the error.
the error message:
2006-07-20 12:56:48,437 WARN [org.apache.struts.action.RequestProcessor] Unhandled Exception thrown: class java.lang.NullPointerException
2006-07-20 12:56:48,437 INFO [STDOUT] ServletException thrown
2006-07-20 12:56:48,437 INFO [STDOUT] javax.servlet.ServletException
2006-07-20 12:56:48,437 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
2006-07-20 12:56:48,437 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
2006-07-20 12:56:48,437 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
2006-07-20 12:56:48,437 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
2006-07-20 12:56:48,437 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
2006-07-20 12:56:48,437 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
2006-07-20 12:56:48,437 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
15:31:31,062 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
15:31:31,062 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at roll.mov.j2ee.common.filters.PersistFilter.doFilter(PersistenceFilter.java:160)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
15:31:31,156 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
15:31:31,156 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
15:31:31,156 INFO [STDOUT] at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
15:31:31,156 INFO [STDOUT] at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
15:31:31,156 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
15:31:31,156 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
15:31:31,156 ERROR [PersistFilter] Exception object caught by servlet persist filter.
15:31:31,171 ERROR [[action]] Servlet.service() for servlet action threw exception
roll.mov.j2ee.common.exceptions.RollMovException: Error caught
begin nested exception:
javax.servlet.ServletException: Servlet execution threw an exception
end nested exception:
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at roll.mov.j2ee.common.filters.PersistenceFilter.doFilter(PersistenceFilter.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)I check in docjar.com, seems like the the line in requestprocessor.java that thrown this exception is
return (handler.execute(exception, config, mapping, form, request, response)); where handler is org.apache.struts.action.ExceptionHandler
any idea guys..
Thanks in advance
pdt -
Strange behavior when using servlet filter with simple index.htm
I am new to J2EE development so please tolerate my ignorance. I have a web application that starts with a simple index.htm file. I am using a servlet filter throughout the website to check for session timeout, redirecting the user to a session expiration page if the session has timed out. When I do something as simple as loading the index.htm page in the browser, the .css file and one image file that are associated, or referenced in the file are somehow corrupted and not being rendered. How do I get the filter to ignore css and image files??? Thank you!!
The servlet filter:
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SessionTimeoutFilter implements Filter {
String[] excludedPages = {"SessionExpired.jsp","index.htm","index.jsp"};
String timeoutPage = "SessionExpired.jsp";
public void destroy() {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
//httpServletResponse.setHeader("Cache-Control","no-cache");
//httpServletResponse.setHeader("Pragma","no-cache");
//httpServletResponse.setDateHeader ("Expires", 0);
String requestPath = httpServletRequest.getRequestURI();
boolean sessionInvalid = httpServletRequest.getSession().getAttribute("loginFlag") != "loggedIn";
System.out.println(sessionInvalid);
boolean requestExcluded = false;
System.out.println(requestExcluded);
for (int i=0;i<excludedPages.length;i++){
if(requestPath.contains(excludedPages)){
requestExcluded = true;
if (sessionInvalid && !requestExcluded){
System.out.println("redirecting");
httpServletResponse.sendRedirect(timeoutPage);
// pass the request along the filter chain
chain.doFilter(request, response);
public void init(FilterConfig arg0) throws ServletException {
//System.out.println(arg0.getInitParameter("test-param"));
The index.htm file (or the relevant portion)<HTML>
<Head>
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="RTEStyleSheet.css" rel="stylesheet" type="text/css">
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<FORM NAME="Login" METHOD="POST" ACTION="rte.ServletLDAP"><!-- Branding information -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" align="left"><img src="images/top_logo_new2.gif">
</td>
<td width="37%" align="center"></td>
<td width="33%" align="right"></td>
</tr>
</table>
My web.xml entry for the filter: <filter>
<description>
Checks for a session timeout on each user request, redirects to logout if the session has expired.</description>
<display-name>
SessionTimeoutFilter</display-name>
<filter-name>SessionTimeoutFilter</filter-name>
<filter-class>SessionTimeoutFilter</filter-class>
<init-param>
<param-name>test-param</param-name>
<param-value>this is a test parameter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SessionTimeoutFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>Hi,
Try adding CSS files and images to the excluded Pages. -
Hi, all
I work on a web application running on a Jboss server and i would like to filter all the http request in order to save it in a database. (i save those informations for manage web stats).
I suppose i may use servlet filter, but i don't know the operation of this
Does anyone could help me giving some example and the protocol to set up this on the server (file server configuration as web.xml)Well here is what I know. I hope it helps.....
First thing is to create a class that implements the "javax.servlet.Filter" interface. But there are also other Filter interfaces that you could use depending on what you want: Filter, FilterChain, and FilterConfig.
You have to implement the init(), destroy() and doFilter() methods (I ommitted the arguments).
But most of your work will be done in the doFilter () method. You could extract request information from one of the arguments in these method and have a datasource connection to save to your back-end.
Something like :
public void doFilter( ServletRequest request, ServletResponse responce, FilterChain chain ) throws ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
backEndDelegate.saveInformation( request.getRemoteAddr(), request.getRemoteHost() );
chain.doFilter( request, responce );
}Second, you need to configure the Filter. In the web.xml file add the following tags:
<filter>
<filter-name>StatsFilter</filter-name>
<description>Logs Web Stats to the back end</description>
<filter-class>com.yourpackage.StatsFilter</filter-class>
<!-- you can also pass parameters to the StatsFilter -->
<!--
<init-param>
<param-name>some parameter</param-name>
<param-value>some parameter</param-value>
</init-param>
-->
</filter>
<filter-mapping>
<filter-name>StatsFilter</filter-name>
<filter-pattern>*.jsp</filter-pattern>
</filter-mapping>That is just a little example. You can associate a filter with a Servlet using the <filter-mapping> tags too. And you can also do filter chains, but I don't feel like going there.
I sure hope that it was helpful. If not then "RTFM" -
Error in importing javax.servlet.ServletConfig;
Hi
I am fairly new to servlets technology
while importing package javax.servlet.ServletConfig; i got error Create class "ServletConfig" in package javax.servlet
I'm using eclipse IDEWhich project have you created in eclipse?
Java or J2EE project?
If its a J2EE project, the jars will be included automatically in the lib
but if its a Java project, you will have to include the servlet-api.jar in the classpath. -
Javax.servlet.ServletContext cannot be resolved in Eclipse
I am loading my project in Eclipse, I am getting this error :
The type[b] javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required .class files
I have set all the libraries, how can make eclipse avaliable with this classWhich libraries have you set?
javax.servlet.ServletContext would be in the J2EE servlet API.
In tomcat this is [TOMCAT]/common/lib/servlet-api.jar
In other containers it might be j2ee.jar -
Can any one tell why after importing javax.servlet.* and javax.servlet.http is not getting resolved in eclipse 3.2 IDE.
right click on the project in the navigator window and select properties.
you will get property window and then select library tab and click the add library button to add the jar file in which javax.serv... packages are defined.
Maybe you are looking for
-
HT1766 How do I move a backed up app from my Mac to my iPad?
How do I move a backed up app from my Mac to my iPad?
-
Want to make phone calls via bluetooth on my iPhone from iPad
I can link my Garmin GPS to my iPhone via Bluetooth and make or receive phone calls. I would like an iPas app that provides the sametype functionality including: Make calls Receive calls Look uphone numbers Is this possible? Using what app?
-
Idoc - codcmt01 throwing an error.
Hi all, I am trying an IDOC to IDOC scenario where CODCMT01 is sent from my R3 system to XI and back to my R3 system. When I am trying to trigger my IDOC from WE19, it says IDOC sent to external system. But, when I check in the transaction SM58, I fi
-
Where do I set the "scenario" iview field in MSS
I am using the MSS Lauch Pad (for ECC 6) but cannot find the iview and parameter to set "viewgroup" and "scenario". Could anyone give me details? Thanks Patrick
-
See I have this code. with parameters PARAMETERS: pdate(6) TYPE n OBLIGATORY, tble1(20) TYPE C OBLIGATORY, tble2(20) TYPE C OBLIGATORY, ccode(20) TYPE C. My job is to output a Report should show all BUKRS