1 Reply Latest reply on Jul 31, 2006 12:32 AM by Fairoz Sharif

    Filter error after setting character encoding in LogFilter.j

    mike frank Newbie

      I was trying to set the request character encoding to utf-8, but got an error after the change. The change was in doFilter() in LogFilter.java. Here is the code that does that:

      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
      HttpServletRequest request = (HttpServletRequest) servletRequest;

      // ADDED THESE 2 LINES
      request.setCharacterEncoding("UTF-8");
      filterChain.doFilter(servletRequest, servletResponse);


      log.debug("request "+request.getRequestURL());

      Enumeration enumeration = request.getParameterNames();
      while (enumeration.hasMoreElements()) {
      String paramName = (String) enumeration.nextElement();
      log.debug("request parameter ["+paramName+"]="+request.getParameter(paramName));
      }

      HttpSession session = request.getSession();
      enumeration = session.getAttributeNames();
      while (enumeration.hasMoreElements()) {
      String attributeName = (String) enumeration.nextElement();
      log.debug("session parameter ["+attributeName+"]="+session.getAttribute(attributeName));
      }

      filterChain.doFilter(servletRequest, servletResponse);
      }



      Here is the error trace:

      21:12:34,980 DEBUG [LogFilter] request parameter [login:username]=cookie monster

      21:12:34,980 DEBUG [LogFilter] request parameter [login_SUBMIT]=1
      21:12:34,980 DEBUG [LogFilter] request parameter [login:_link_hidden_]=
      21:12:34,980 DEBUG [LogFilter] request parameter [login:_id2]=Log In
      21:12:34,990 DEBUG [LogFilter] session parameter [org.apache.myfaces.application
      .jsp.JspStateManagerImpl.SERIALIZED_VIEW-/login.jsp]=[Ljava.lang.Object;@132cb29

      21:12:34,990 DEBUG [LogFilter] session parameter [javax.faces.request.charset]=I
      SO-8859-1
      21:12:34,990 DEBUG [LogFilter] session parameter [userBean]=org.jbpm.webapp.bean
      .UserBean@12f2b32
      21:12:35,000 ERROR [[FacesServlet]] Servlet.service() for servlet FacesServlet t
      hrew exception
      javax.faces.el.EvaluationException: Cannot get value for expression '#{userBean.
      userSelectItems}'
      at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java
      :399)
      at javax.faces.component.UISelectItems.getValue(UISelectItems.java:55)
      at javax.faces.component._SelectItemsIterator.hasNext(_SelectItemsIterat
      or.java:92)
      at javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.ja
      va:46)
      at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:52)
      at javax.faces.component.UIInput.validate(UIInput.java:269)
      at javax.faces.component.UIInput.processValidators(UIInput.java:144)
      at javax.faces.component.UIForm.processValidators(UIForm.java:68)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBa
      se.java:417)
      at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:14
      2)
      at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(Lifecyc
      leImpl.java:208)
      at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java
      :76)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
      at org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:62)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:81)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:178)
      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
      ipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:159)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:59)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
      ssConnection(Http11Protocol.java:744)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
      int.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
      kerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.faces.el.EvaluationException: org.jbpm.webapp.bean.UserBean
      at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverI
      mpl.java:78)
      at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELPars
      erHelper.java:532)
      at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
      at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java
      :380)
      ... 34 more
      Caused by: javax.faces.el.EvaluationException: Bean: org.jbpm.webapp.bean.UserBe
      an, property: userSelectItems
      at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolv
      erImpl.java:404)
      at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverI
      mpl.java:71)
      ... 37 more
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolv
      erImpl.java:400)
      ... 38 more
      Caused by: java.lang.NullPointerException
      at org.jbpm.webapp.bean.UserBean.getUsers(UserBean.java:53)
      at org.jbpm.webapp.bean.UserBean.getUserSelectItems(UserBean.java:61)
      ... 43 more
      21:12:36,873 DEBUG [JbpmContextInfo] creating jbpm context with service factorie
      s '[message, scheduler, logging, persistence, authentication]'
      21:12:36,873 DEBUG [JbpmContext] creating JbpmContext
      21:12:36,873 DEBUG [DbPersistenceServiceFactory] creating persistence service
      21:12:36,873 DEBUG [DbPersistenceService] creating hibernate session

      Thanks!