2010-12-10 12 views
9

Ben bir JSF yedekleme fasulye aşağıdaki yöntemi:NumberFormatException

public List<Rent> getTopMemebers(){ 
    return rentDAO.findByMonthAndYear(MonthReport, YearReport); 
} 

bir datatable bu görüntülendiği ediyorum:

<p:dataTable value="#{rentController.topMemebers}" var="item"> 
    <p:column> 
     <h:outputText value="#{item.rentid}"/> 
    </p:column> 
    ... 
</p:dataTable> 

Ama şu istisna var:

SEVERE: Error Rendering View[/admin/index.xhtml] 
java.lang.NumberFormatException: For input string: "rentid" 
     at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) 
     at java.lang.Integer.parseInt(Integer.java:449) 
     at java.lang.Integer.parseInt(Integer.java:499) 
     at javax.el.ArrayELResolver.toInteger(ArrayELResolver.java:375) 
     at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:195) 
     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) 
     at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) 
     at com.sun.el.parser.AstValue.getValue(AstValue.java:116) 
     at com.sun.el.parser.AstValue.getValue(AstValue.java:163) 
     at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219) 
     at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102) 
     at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) 
     at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) 
     at javax.faces.component.UIOutput.getValue(UIOutput.java:168) 
     at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) 
     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338) 
     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) 
     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:489) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:416) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:164) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:80) 
     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) 
     at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) 
     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848) 
     at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55) 
     at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43) 
     at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:118) 
     at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:48) 
     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) 
     at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380) 
     at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126) 
     at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:157) 
     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127) 
     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) 
     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) 
     at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:113) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:820) 
     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) 
     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:517) 
     at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:488) 
     at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379) 
     at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336) 
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314) 
     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:104) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at com.mcgraw.controller.UserLoginFilter.doFilter(UserLoginFilter.java:59) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) 
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) 
     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) 
     at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) 
     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) 
     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) 
     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) 
     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) 
     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) 
     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) 
     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) 
     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) 
     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) 
     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) 
     at com.sun.grizzly.ContextTask.run(ContextTask.java:69) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) 
     at java.lang.Thread.run(Thread.java:619) 

WARNING: ApplicationDispatcher[/mcGrawLibPro-war] PWC1231: Servlet.service() for servlet Faces Servlet threw exception 
java.lang.NumberFormatException: For input string: "rentid" 
     at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) 
     at java.lang.Integer.parseInt(Integer.java:449) 
     at java.lang.Integer.parseInt(Integer.java:499) 
     at javax.el.ArrayELResolver.toInteger(ArrayELResolver.java:375) 
     at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:195) 
     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) 
     at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) 
     at com.sun.el.parser.AstValue.getValue(AstValue.java:116) 
     at com.sun.el.parser.AstValue.getValue(AstValue.java:163) 
     at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219) 
     at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102) 
     at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) 
     at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) 
     at javax.faces.component.UIOutput.getValue(UIOutput.java:168) 
     at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) 
     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338) 
     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) 
     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:489) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:416) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:164) 
     at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:80) 
     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) 
     at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) 
     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848) 
     at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55) 
     at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43) 
     at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:118) 
     at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:48) 
     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) 
     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) 
     at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380) 
     at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126) 
     at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:157) 
     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127) 
     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) 
     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) 
     at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:113) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:820) 
     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) 
     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:517) 
     at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:488) 
     at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379) 
     at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336) 
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314) 
     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:104) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at com.mcgraw.controller.UserLoginFilter.doFilter(UserLoginFilter.java:59) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) 
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) 
     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) 
     at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) 
     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) 
     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) 
     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) 
     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) 
     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) 
     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) 
     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) 
     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) 
     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) 
     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) 
     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) 
     at com.sun.grizzly.ContextTask.run(ContextTask.java:69) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) 
     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) 
     at java.lang.Thread.run(Thread.java:619) 

Nasıl oluşur ve nasıl düzeltebilirim? \

+3

Yığın izi eklemek için düzenleme yapabilir misiniz? Böylece, uygulamanızın hangi katmanının istisna attığını görebiliriz? – Guillaume

+0

Ve görünümde '# {item.itemid}' kullanan JSF kodunun ilgili kısmı. Tüm bu JPA kodları ve diğer "iyi çalışan" girdiler sorunla ilgisizdir. Sadece soruya gürültü katıyor. – BalusC

+0

ben düzenlendim, lütfen kontrol edin, teşekkürler – MYE

cevap

22

Yani,

<h:outputText value="#{item.rentid}" /> 

bu neden oluyor:

java.lang.NumberFormatException: For input string: "rentid" 
    ... 
    at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:195) 
    ... 
    at javax.faces.component.UIOutput.getValue(UIOutput.java:168) 

Eğer çalıştırdığınız düşünüyorum kodu çalıştırıyor musunuz? ArrayELResolver'un stacktrace'de yer alması, #{item}'un 'unObject[] gibi bir dizi olduğunu gösterir. Dizi değerleri, yalnızca #{item[0]} gibi bir tamsayı dizini ile elde edilebilir, ancak bu istisnaya neden olan rentid#{item.rentid} olarak erişebilirsiniz.

o RentController#getTopMembers() bir List<Rent> değil List<Object[]> döner ve RentController doğru sürümünün #{rentController} yönetilen fasulye olarak ilan edilmiştir emin olun.

+0

evet sağ BalusC 2 parametre entitymanager.createNativeQuery (String, class result) ile yeniden sorgu oluşturmalı; Çok teşekkür ederim – MYE

+0

Rica ederim. – BalusC

+0

Bu aynı sorunu yaşadım. Orm.xml içerisindeki '' etiketinin içinde tanımlanmış SQL vardı. 'Sonuç sınıfı' özniteliğini kaçırıyordu. Bunu ekledikten sonra çalıştı. İnşallah bu ders, problemi googling ettikten sonra (bu gibi) bu yazının üzerine gelen aynı sorunu olan başka birine yardım edecektir. –