Java 动态报表导出pdf类未找到异常错误

Java 动态报表导出pdf类未找到异常错误,java,itext,Java,Itext,我正在尝试使用 动态报表开放源代码库 my pom.xml: <dependencies> <!-- https://mvnrepository.com/artifact/net.sourceforge.dynamicreports/dynamicreports-core --> <dependency> <groupId>net.sourceforge.dynamicreports</groupId> <ar

我正在尝试使用 动态报表开放源代码库

my pom.xml:

<dependencies>
  <!-- https://mvnrepository.com/artifact/net.sourceforge.dynamicreports/dynamicreports-core -->
<dependency>
    <groupId>net.sourceforge.dynamicreports</groupId>
    <artifactId>dynamicreports-core</artifactId>
    <version>6.1.0</version>
</dependency>
为什么动态报表模块没有这种依赖关系?我是否应该添加或使用其他新方法? 下面是dependency:tree的输出

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building dynamicreport 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
[INFO] Downloading: http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
[INFO] Downloading: http://jaspersoft.jfrog.io/jaspersoft/jr-ce-releases/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
[WARNING] The POM for com.google.zxing:core:jar:3.3.3 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.434 s
[INFO] Finished at: 2019-12-26T11:23:22+05:30
[INFO] Final Memory: 11M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project dynamicreport: Could not resolve dependencies for project com.sample:dynamicreport:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at net.sourceforge.dynamicreports:dynamicreports-core:jar:6.1.0 -> net.sf.jasperreports:jasperreports:jar:6.9.0 -> com.lowagie:itext:jar:2.1.7.js6: Failed to read artifact descriptor for com.lowagie:itext:jar:2.1.7.js6: Could not transfer artifact com.lowagie:itext:pom:2.1.7.js6 from/to jaspersoft-third-party (http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/): Access denied to http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom. Error code 407, Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  ) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
任何帮助都将不胜感激

缺少依赖项
iText
? 您可能缺少导出为PDF所需的名为
iText
的依赖项。因此,编译器抛出一个NoClassDefFoundError,表示缺少以下类:
com.lowagie.text.DocumentException

决议0: 重新导入maven项目(
mvn clean install
),并确保依赖项
iText
或至少一个名为
com.lowagie.text.DocumentException
的类位于类路径中

或者您可以使用来自的较新版本。 这是基于6.5.1版,该版本再次使用iText将报告导出为PDF

如果在的依赖项中搜索
iText
,您将发现:


com.lowagie


通过列出/解决POM中的依赖项并通过建议的命令澄清和更新问题后:

  • (Maven关于通过展开依赖关系树来显示依赖关系冲突的指南:在之前下载)
  • (仅尝试下载所有依赖项/JAR)
。。似乎有以下(潜在)根本原因

问题似乎 当Maven试图从外部存储库解析或下载依赖关系时,出现了与代理相关的访问错误
():

错误代码407,需要代理身份验证(ISA服务器需要授权才能完成请求。拒绝访问Web代理筛选器。)

您的代理可能会阻止访问远程POM和/或下载JAR依赖项。 有两种可能的解决方案:

解决方案1:将Maven设置为使用代理 请参阅上的此问题和答案。这将告诉您如何编辑代理相关配置的Maven
settings.xml
,以及如何设置CNTLMHTTP轻量级Maven扩展

解决方案2:手动下载并安装缺少的依赖项 首先,通过Jaspersoft的存储库(JFrog Artifactory)的浏览器页面手动下载JAR文件:


然后转到您当地的Maven repo。

我使用它作为iText的更新。迁移真正的遗留(如感谢Nigel,我必须使用动态报告开源模块我希望它在内部使用itext,因为只有我会使用itext请upvote@hc_dev ans如果它修复了您的问题或hc_dev ans没有修复请让我们知道Hi Madhesh,请回答您的问题并添加两个maven命令的输出(正如您在comment+中所做的一样,正如Nigel所建议的那样)。感谢您的更新,我们已经接近解决方案@Madhesh。我发现了一个可能的407/代理问题,研究并更新了我的答案。请始终密切关注maven日志记录,尤其是在代理之后:-(谢谢,我正在使用maven更新的依赖项。但是该依赖项不包含itext,@Madhesh您是否通过列出依赖项?如果
itext
未列出,请尝试单独包含它。但是包含不包含,因此它不仅会在编译时包含,而且会在运行时包含。当我运行该命令时,我收到此错误,失败。)ed在net.sourceforge.dynamicreports:dynamicreports核心:jar:6.1.0->net.sf.jasperreports:jasperreports:jar:6.9.0->com.lowagie:itext:jar:2.1.7.js6:无法读取com的工件描述符。lowagie:itext:jar:2.1.7.js6:无法将工件从/传输到jaspersoft第三方(:拒绝访问。使用“mvn dependency:tree-Dverbose”显示dependency树,然后使用输出更新您的问题,这样我们就可以看到实际存在的内容
Exception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
    at net.sf.dynamicreports.jasper.transformation.ExporterTransform.pdf(ExporterTransform.java:440)
    at net.sf.dynamicreports.jasper.transformation.ExporterTransform.transform(ExporterTransform.java:134)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.export(JasperReportBuilder.java:891)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toPdf(JasperReportBuilder.java:731)
    at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toPdf(JasperReportBuilder.java:720)
    at com.sample.dynamicreport.App.main(App.java:33)
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building dynamicreport 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
[INFO] Downloading: http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
[INFO] Downloading: http://jaspersoft.jfrog.io/jaspersoft/jr-ce-releases/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
[WARNING] The POM for com.google.zxing:core:jar:3.3.3 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.434 s
[INFO] Finished at: 2019-12-26T11:23:22+05:30
[INFO] Final Memory: 11M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project dynamicreport: Could not resolve dependencies for project com.sample:dynamicreport:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at net.sourceforge.dynamicreports:dynamicreports-core:jar:6.1.0 -> net.sf.jasperreports:jasperreports:jar:6.9.0 -> com.lowagie:itext:jar:2.1.7.js6: Failed to read artifact descriptor for com.lowagie:itext:jar:2.1.7.js6: Could not transfer artifact com.lowagie:itext:pom:2.1.7.js6 from/to jaspersoft-third-party (http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/): Access denied to http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom. Error code 407, Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  ) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException