p:dataTable和MalformedByteSequenceException

时间:2012-03-05 13:35:37

标签: jsf-2 primefaces

当我尝试在项目中添加标记p:dataTable时收到此错误:

An Error Occurred:
    Byte non valido 1 della sequenza UTF-8 a 1 byte.
    - Stack Trace
    com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Byte non valido 1 della sequenza UTF-8 a 1 byte.
    at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:687)
    at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:557)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1750)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(XMLEntityScanner.java:494)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2647)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
    at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:423)
    at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:399)
    at com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:124)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:305)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$100(DefaultFaceletFactory.java:93)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$1.newInstance(DefaultFaceletFactory.java:160)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$1.newInstance(DefaultFaceletFactory.java:158)
    at com.sun.faces.facelets.impl.DefaultFaceletCache$1.newInstance(DefaultFaceletCache.java:83)
    at com.sun.faces.facelets.impl.DefaultFaceletCache$1.newInstance(DefaultFaceletCache.java:78)
    at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114)
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:121)
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:62)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:256)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:201)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:764)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    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:594)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at it.cyborg.cdg.jsfClasses.util.MultipartFilter.doFilter(MultipartFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
    - Component Tree
    <UIViewRoot id="j_id1" inView="true" locale="it_IT" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/progetti/List.xhtml"/>
    - Scoped Variables
    Request Parameters
    Request Parameters
    Name
    Value
    j_idt24
    j_idt24
    j_idt24:j_idt25
    j_idt24:j_idt25
    View Attributes
    View Attributes
    Name
    Value
    None
    Request Attributes
    Request Attributes
    Name
    Value
    None
    Flash Attributes
    Flash Attributes
    Name
    Value
    None
    Session Attributes
    Session Attributes
    Name
    Value
    logicBean
    it.cyborg.cdg.logic.LogicBean@9ba2b1
    stiliPortaleController
    it.cyborg.cdg.jsfClasses.StiliPortaleController@1d62330
    userBean
    it.cyborg.cdg.UserBean@1a04a2f
    Application Attributes
    Application Attributes
    Name
    Value
    csfcff
    com.sun.faces.context.flash.ELFlash@665898
    5-mar-2012 12.34.10 - Generated by Mojarra/Facelets
    <br/>

哪里可能是问题?     
xhtml页面(包含h:dataTable)修改后将dataTable和column标签替换为PrimeFaces,修改该类以返回List对象而不是DataModel ...
我看到了这个例子:
http://www.primefaces.org/showcase-labs/ui/datatableSorting.jsf     
添加排序选项似乎很简单,因为我不能在java的类中添加任何特定的代码...
不过这是我的代码:
    List.xhtml:


    ...
    <p:dataTable value="#{progettiController.itemsList}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px" id="dataTable">
    <p:column sortBy="#{item.id}">
    <f:facet name="header">
    <h:outputText value="#{bundle.ProgettiTitle_id}"/>
    </f:facet>
    <h:commandLink action="#{progettiController.prepareView}" value="#{item.id}"/>
    </p:column>
    <p:column sortBy="#{item.oggetto}">
    <f:facet name="header">
    <h:outputText value="#{bundle.ProgettiTitle_oggetto}"/>
    </f:facet>
    <h:outputText value="#{item.oggetto}"/>
    </p:column>
    ...

ProgettiController.java:


    ...
    private List itemsList;
    ...
    public void setItemsList()
    {
    itemsList=logic.method.findProgettiByQuery(); //--- a method that returns a sublist of Progetti and that worked correctly
    }
    ...
    public List getProgetti()
    {
    return itemsList;
    }
    ...

感谢您的帮助!

更新:好的,我想我明白问题出在哪里......它不在p:datatable而不在p:列中,但是我能够从网络中复制和粘贴..有时空格字符无法正确识别,所以我必须用新空格替换所有空格......

1 个答案:

答案 0 :(得分:1)

我不知道您使用的是哪个PF版本,但我使用的版本(2.2)没有属性rowClasses

但是,h:dataTable具有此属性。但我不知道Primefaces如何处理这种情况。根据我的经验,有时它可以使用底层jsf组件的属性,有时不会。

错误当然有点普遍和误导。看起来像是来自较低xml解析层的未处理异常。