仅在 EAR 网页中使用 WebLogic 的 JDeveloper 11.1 中 Jasper 报告“package net.sf.jasperreports.engine 不存在”异常

问题描述 投票:0回答:3

我正在使用 JDeveloper 11.1、Oracle 11 和 TIBCO JasperReports 6.0.1。

我在尝试从我的网页(ViewController)生成 Jasper 报告时遇到问题,同时使用 ApplicationModule(模型 - EJB)来执行此操作。最后,PDF 文件必须通过电子邮件发送,这就是我将其放入模型项目的原因。

如果我执行ApplicationModule,它工作正常,没有例外,PDF 生成和发送得很好。

但是,如果我从网页开始执行客户端方法,我会得到这个异常:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:4: package net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.*;
^
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:5: package net.sf.jasperreports.engine.fill does not exist
import net.sf.jasperreports.engine.fill.*;
^
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:18: cannot find symbol
symbol: class JREvaluator
public class Simple_Blue_1429546047623_56582 extends JREvaluator
                                                     ^
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:25: cannot find symbol
symbol  : class JRFillParameter
location: class Simple_Blue_1429546047623_56582
    private JRFillParameter parameter_REPORT_LOCALE = null;
            ^
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:26: cannot find symbol
symbol  : class JRFillParameter
location: class Simple_Blue_1429546047623_56582
    private JRFillParameter parameter_Description = null;
            ^
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:27: cannot find symbol
symbol  : class JRFillParameter
location: class Simple_Blue_1429546047623_56582
    private JRFillParameter parameter_JASPER_REPORT = null;
            ^
C:\Users\rodmar\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\Simple_Blue_1429546047623_56582.java:28: cannot find symbol
symbol  : class JRFillParameter
location: class Simple_Blue_1429546047623_56582
    private JRFillParameter parameter_REPORT_VIRTUALIZER = null;
            ^

我只是粘贴一个片段。

我使用其他 .jar 作为 POI,用于读取 .xlsx 文件并将其插入数据库,所以我不知道为什么我可以毫无问题地访问 POI,但同时我没有可用的 Jasper Reports。

我已经在网上搜索了一些解决方案,但没有任何解决方案可以解决我的问题。我获得了一些有关 jdt-compiler 的信息,但我没有在 JasperReports 套件中找到它。我的项目真的是一团糟,里面有所有这些库,也许我缺少或添加了太多?

我现在的EAR项目是这样的:

EAR project

EAR\lib:

EAR\lib contents

这是 jar 设置或类似问题的一种问题。我已经找到了这个页面,但它真的很奇怪,我不认为我的问题有那么复杂。

http://docs.oracle.com/cd/E25178_01/fusionapps.1111/e15524/adv_wls_e.htm

编辑1:

我尝试使用此代码查看我的类路径:

ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for (URL url: urls) {
    logger.info(String.format("Classpath: %s.", url.toString()));
}

我得到了这个输出。 POI 不在这里,但为什么我使用它没有任何问题,而我却无法使用 JasperReports?

1) WebLogic 10.3 基本安装中默认使用 POI.jar 吗?

编辑2:

我发现在 WebLogic 中需要访问 weblogic.utils.classloaders.GenericClassLoader,它会向我发送属于此 EAR 应用程序的所有库。使用它,Jasper Reports 可用,但我不知道如何才能成功访问它们......

GenericClassLoader jre = (GenericClassLoader) JREvaluator.class.getClassLoader();
logger.info(String.format("jre: %s, s.", jre, jre.getClassPath()));
jar jasper-reports weblogic
3个回答
3
投票

嗯,正如有人说有必要使用jdt-compiler-3.1.1.jar。我将其添加到 /lib 文件夹中,现在它可以工作了。

真的很奇怪,这个.jar并不在TIBCO Jasper Reports 6.0.0的安装产品中,实际上我一直下降到JR 3.7.6,这是最低版本。该文件来自 28/12/2008...


1
投票

我使用了 eclipse ecj-4.3.1.jar 并且它有效。


1
投票

首先检查jasperReports的依赖关系 - 例如版本6.1.0 - https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.1.0 l

通过这个,您可以查看您的 lib 目录(webApp)或 .jar 中是否缺少任何依赖项(如果它是 java 的主应用程序)。

这个错误也发生在我身上,我通过添加依赖解决了

<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.3.1</version>
© www.soinside.com 2019 - 2024. All rights reserved.