0

嗨,我不时遇到异常(无法重现)并且不知道该怎么办..

这是堆栈跟踪:

java.lang.NumberFormatException.forInputString 13:46:52,015 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[atlasvirtualdomain].[/].[Faces Servlet]] (http--0.0.0.0-8040-399) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NumberFormatException: For input string: "+O.undefined"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [rt.jar:1.7.0_07]
    at java.lang.Integer.parseInt(Integer.java:492) [rt.jar:1.7.0_07]
    at java.lang.Integer.valueOf(Integer.java:582) [rt.jar:1.7.0_07]
    at javax.faces.convert.IntegerConverter.getAsObject(IntegerConverter.java:116) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectPathParams(ParameterInjector.java:85) [prettyfaces-jsf2-3.3.3.jar:]
    at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectParameters(ParameterInjector.java:54) [prettyfaces-jsf2-3.3.3.jar:]
    at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:102) [prettyfaces-jsf2-3.3.3.jar:]
    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95) [myfaces-extcdi-bundle-jsf20-1.0.5.jar:1.0.5]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:82) [classes:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at utils.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:32) [classes:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145) [prettyfaces-jsf2-3.3.3.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at utils.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:32) [classes:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:840) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:622) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:560) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:488) [jbossweb-7.0.13.Final.jar:]
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137) [prettyfaces-jsf2-3.3.3.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at utils.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:32) [classes:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]

我猜漂亮脸蛋与此有关:

at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectPathParams(ParameterInjector.java:85) [prettyfaces-jsf2-3.3.3.jar:]
at com.ocpsoft.pretty.faces.beans.ParameterInjector.injectParameters(ParameterInjector.java:54) [prettyfaces-jsf2-3.3.3.jar:]
at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:102) [prettyfaces-jsf2-3.3.3.jar:]

我用:

  • JBoss AS 7.1
  • 内置
  • 莫哈拉
  • JSF 2.1
  • CODI
  • 漂亮脸蛋

编辑:

我以某种方式设法修复它(见我的回答),但我不明白我的修复是如何工作的......

有时会调用此 url(在所有 cookie 被删除或从未存在之后):

http://.../firsat/655/something/;jsessionid=uNCQNxYxmmuQak6bcfpfZTG-.undefined

为什么 jsessionid 与我的 prettytime 规则混淆了?我...

4

2 回答 2

3

很难告诉您那里到底出了什么问题,但我可以帮助您了解它发生在哪个时间点。

PrettyFaces 阶段侦听器在 RESTORE_VIEW 阶段之后启动。在这个阶段 PrettyFaces 处理所有查询和路径参数。由于错误发生在 期间ParameterInjector.injectPathParams(),问题与某些路径参数有关。

在注入发生之前,PrettyFaces 检查参数绑定到的 bean 属性的类型。PrettyFaces 然后检查 JSF 是否为该类型注册了任何转换器。根据堆栈跟踪,该字段似乎是一个整数,因为 PrettyFaces 调用了IntegerConverter. 转换器用于将路径参数的值从 URL(为 String)转换为目标类型(为 int)。

例外情况是,输入字符串+O.undefined不能转换为整数。所以看起来这个字符串是请求的 URL 的一部分。

看看这个例子。假设您有这样的映射:

<url-mapping id="userDetails">
  <pattern value="/user/#{userBean.id}" />
  <view-id value="/faces/user-details.jsf" /> 
</url-mapping>

如果由于某种原因有人请求 URL /user/+O.undefined,您将得到这个异常。所以我认为你必须找到发生这种情况的原因。也许您会在访问日志中找到线索?!?

顺便说一句:您还可以使用正则表达式来确保仅在路径参数与某个表达式匹配时才处理映射。像这样的东西:

<url-mapping id="userDetails">
  <pattern value="/user/#{ /[0-9]+/ userBean.id }" />
  <view-id value="/faces/user-details.jsf" /> 
</url-mapping>

有关详细信息,请参阅PrettyFaces 文档中的这一章。

于 2012-11-16T16:02:23.493 回答
0

该错误是使用“id”作为 url 参数的名称:

  <url-mapping id="articleedit2"> 
      <pattern value="/duzenle/#{id: articleEdit.article_id}/" /> 
      <view-id value="/faces/article_edit.xhtml" />
      <action>#{articleEdit.initForEdit()}</action>
  </url-mapping>

然后用java重定向到id(伪代码:Redirect('something?id=123'))。不知何故 jsessionid 混入了这个参数然后......

解决方法是将其重命名为 id 以外的名称 :)

编辑:我又遇到了这个错误......仍然不知道是什么触发了它

于 2012-11-16T16:01:55.430 回答