java - EAR 中的 java.lang.NoClassDefFoundError
问题描述
我创建了一个 EAR,其中有一个 WAR 并部署到 wildfly 服务器。该项目需要 sapjco3.jar 才能运行。我将 jar 放在服务器上并在 EAR 中创建一个 XML 来使用它。
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry -->
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->
<!-- This is the top level ear module, which contains all the classes in the EAR's lib folder -->
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
<!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute -->
<dependencies>
<module name="deployment.nana-app.ear" export="true" />
<module name="deployment.sapjco3.jar" export="true" />
</dependencies>
<!-- These add additional classes to the module. In this case it is the same as including the jar in the EAR's lib directory -->
<resources>
</resources>
</deployment>
</jboss-deployment-structure>
部署成功,但是当我使用它时发生以下错误。
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.JCo
... 206 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.JCo
at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:77)
at com.SAPcall.SAPcallBean.ContractCreate(SAPcallBean.java:586)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jar 位置是正确的,因为我有另一个 WAR 使用它并且那个可以工作。那么我的项目有什么问题?我需要在战争中添加配置吗?谢谢。
解决方案
推荐阅读
- css - 我如何隐藏从身体溢出的一切?
- python - 暂停 for 循环以等待按钮按下
- dart - 列表添加地图对象
- swiftui - SwiftUI 2 中的 Big Sur 风格侧边栏 Mac Catalyst
- c# - 了解批量插入的 SQL Server 合并问题
- python - 乘以长度为 1 的熊猫系列时出现键错误“0”
- javascript - 在 React 中使用多个异步事件处理状态的策略
- ffmpeg - 将 .mp4 转换为 .mkv 会改变数据保真度吗?
- c# - Unity3D c# 2D Game Camera Follow 正在跳跃
- .net-core - Aspnet Core 3.1 MVC Razor 页面在使用 Identity Server 4 OpenIdConnect 进行身份验证后得到 302