p:dataExporter throws java.lang.NoClassDefFoundError: com/lowagie/text/phrase

强颜欢笑 提交于 2019-12-23 16:48:20

问题


I tried to use the data exporter control of primefaces 3.2. Following is the code:

<p:commandLink value="export" ajax="false">
        <p:dataExporter type="xls" target="dtable" fileName="myfile" />  
    </p:commandLink>
<p:datatable id="dtable" ........../>

When I click on export link, I get the following error:

java.lang.NoClassDefFoundError: com/lowagie/text/phrase

I downloaded itext jar 5.2.1 and included it in my application, still I get the same error. How do I solve it?


回答1:


Try iText 2.1.7 not 5.2.1. http://olex.openlogic.com/packages/itext/2.1.7

I think there are licence conflicts. So primefaces uses 2.1.7

For Excel Export you need Apache POI. Try 3.7: http://archive.apache.org/dist/poi/release/bin/

Edit

(you need only the poi-3.7*.jar and poi-ooxml-3.7*.jar)




回答2:


Go to netbeans, on your project dependency add a new dependency. Type Query type iText 2.1.7 then choose com.lowagie:itext. you should be able to download with dpf :D




回答3:


Just add the following dependency

    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>



回答4:


I was having the same problem, but when i downloaded the jars it doesn't worked. Then I noticed I was using <p:commandLink>, the correct is to use <h:commandLink> for some reason <p:commandLink> won't work.

Don't use:

<p:commandLink > <p:graphicImage value="images/excel.png" width="48"/> <p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" /> </p:commandLink>

instead use:

<h:commandLink > <p:graphicImage value="images/custom/excel.png" width="48"/> <p:dataExporter type="xls" target="table" fileName="tablexls" encoding="UTF-8" /> </h:commandLink>



来源:https://stackoverflow.com/questions/10899368/pdataexporter-throws-java-lang-noclassdeffounderror-com-lowagie-text-phrase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!