我在JSF页面中收到此错误,但我无法在代码中找到错误以纠正错误。如果堆栈跟踪没有指向我自己代码的任何源代码,我该怎么办?
我没有输入或调用值41.5,也无法在源代码中找到搜索值。
WARNING: StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NumberFormatException: For input string: "41.5"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at java.lang.Long.valueOf(Long.java:540)
at com.sun.el.lang.ELSupport.coerceToNumber(ELSupport.java:317)
at com.sun.el.lang.ELSupport.coerceToNumber(ELSupport.java:296)
at com.sun.el.lang.ELSupport.compare(ELSupport.java:103)
at com.sun.el.parser.AstLessThan.getValue(AstLessThan.java:66)
at com.sun.el.parser.AstAnd.getValue(AstAnd.java:63)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:462)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1850)
at com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:527)
at com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:990)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)
at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:204)
at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:121)
at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:58)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)
at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:204)
at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:121)
at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:58)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:744)
导致错误的JSF细分
<p:panel header="Microbiology" rendered="#{patientReportController.currentPatientReport.patientInvestigation.investigation.reportType eq 'Microbiology'}" >
<p:dataTable id="tblMicVals" value="#{patientReportController.currentPatientReport.patientReportItemOfValueType}" var="pv" >
<p:column >
<h:outputLabel value="#{pv.investigationItem.name}" rendered="#{pv.investigationItem.ixItemType eq 'Value'}"></h:outputLabel>
</p:column>
<p:column >
<h:panelGroup rendered="#{pv.investigationItem.ixItemType eq 'Value'}">
<h:panelGroup rendered="#{pv.investigationItem.ixItemValueType eq 'Memo'}" >
<p:inputTextarea id="txtMicMemoVal" style="min-width: 200px;" completeMethod="#{investigationItemValueController.completeValues}" >
</p:inputTextarea>
<p:watermark value="#{pv.lobValue}" for="txtMicMemoVal" />
</h:panelGroup>
<h:panelGroup rendered="#{pv.investigationItem.ixItemValueType eq 'Varchar'}">
<p:selectOneMenu id="cmbMicStrVal" value="#{patientReportController.strEnterVal}" editable="true" style="min-width: 300px!important;" >
<f:selectItem itemLabel="SENSITIVE" itemValue="SENSITIVE" ></f:selectItem>
<f:selectItem itemLabel="Resistant" itemValue="Resistant" ></f:selectItem>
<f:selectItem itemLabel="Intermediate" itemValue="Intermediate" ></f:selectItem>
<f:ajax event="change" execute="@this" listener="#{patientReportController.saveStrVal(pv.id) }" ></f:ajax>
</p:selectOneMenu>
<p:watermark value="#{pv.strValue}" for="cmbMicStrVal" />
</h:panelGroup>
</h:panelGroup>
</p:column>
</p:dataTable>
</p:panel>
在BalusC的回答之后,我可以找到错误的地方。正如他所提到的,我已经使用了内部表达式语言来比较字符串值。
这是确切的地方。 prv.investigationItem.cssTop是一个String。我用它与lt。
<h:panelGroup rendered="#{prv.investigationItem.ixItemType eq 'Value' and prv.investigationItem.ixItemValueType eq 'Memo' and prv.investigationItem.retired eq false and prv.lobValue ne '' and prv.lobValue ne null and prv.investigationItem.cssTop lt 50 }" >
答案 0 :(得分:2)
如果您能够仔细阅读堆栈跟踪,则只能找到罪魁祸首。仔细查看encodeXxx()
方法之后调用的renderView()
方法。类名称提示正在处理哪个组件/渲染器。在堆栈跟踪中从下到上读取它们。
我已经为你做了。根据堆栈跟踪,罪魁祸首在于以下XHTML结构:
<p:panel>
<h:panelGrid>
<h:panelGroup>
<p:panel>
<h:panelGroup>
<ui:repeat>
<x:someComponent rendered="#{??? and ??? lt '41.5'}">
但是,在您发布的JSF细分中,此标记无处可见。因此,您正在查看XHTML文件中的错误位置。
请注意,<x:someComponent>
是一个未知组件,但最有可能是<h:xxx>
组件,问题出在rendered
属性中,该属性由and
组成(或&&
)表达式,其右侧包含lt
(或<
)等式,而右侧依次将"41.5"
作为String
而非a Long
(请注意,您不能将小数存储在Long ...中)并导致所有麻烦。
这应该指导你找到罪魁祸首的正确方向。