有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Ntier应用程序中的java NoClassDefFoundException

我正在为我正在学习的课程建立一个项目,它由4个模块组成

-impl (business logic/dao access)
-ejb  (encapsulates business logic and provides access to it via a remote interface)
-war (web tier)
-ear (contains the war and ejb modules)

impl中的一个实用程序类能够填充H2数据库。它通过运行一个摄取器来实现这一点,该摄取器在进程中读取驻留在maven存储库中的xml文件,并使用各种dao类/方法来摄取数据:

String fileName = "xml/proj-data.xml";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);

当我通过单元测试运行ingestor时,它运行得很好,但是当我对所有内容进行分层时,我会在xml/proj数据上得到NoClassDefFoundException。xml

所以我的基本纲要是:

-the war has dependencies on the impl and ejb modules
-the ejb has dependency on the impl module
-the ear has dependency on the impl, ejb, and war

这是一个maven项目。当我将EAR部署到服务器时,将显示war的起始页(正如我所期望的)

-html页面有一个按钮,按下该按钮时,会向servlet发送帖子 -servlet中注入了一个ejb(通过其远程接口)进行调用。 -ejb方法在impl中回调populate方法,这时异常发生,我得到一个显示异常的网页

我是否也需要在WAR pom文件中声明该存储库


共 (1) 个答案

  1. # 1 楼答案

    在输入问题时,我想我知道问题可能是什么。xml文件所在的存储库在项目的根pom(IMP父级)中声明,而不是在IMP模块的pom中声明。由于impl是与EAR一起打包的模块,因此我可能还需要在impl pom文件中声明存储库