我打包了一个EAR(myear.ear)文件,并将其部署在JBoss EAP 6(即JBoss 7 :)中。
看起来像这样:
lib/
my-common.jar (Custom library containing common classes used by both the WAR and BIZ)
--- (other libraries used by both WAR and BIZ) ---
META-INF/
jboss-deployment-structure.xml (specifies just <ear-subdeployments-isolated>false</ear-subdeployments-isolated> )
my-biz.jar (EJB Module)
META-INF/
beans.xml
MANIFEST.MF
-- java classes --
my-war.war (WAR Module)
WEB-INF/
beans.xml
lib/ (empty! I made a skinny war)
META-INF/
MANIFEST.MF
resources/
-- java classes --
在
my-war.war
中有一个类,该类从my-common.jar
中的类调用方法。这是发生了什么:public class MyWarMember implements Serializable{//my-war.war
public void foo(){
MyCommonMember.deepCopy(this);
}
}
---------------------------------------------------------------------
public class MyCommonMember{//my-common.jar
public static Object deepCopy(Serializable obj){
ObjectOutputStream oos .....
...
oos.writeObject(obj);
....
ObjectInputStream ois ....;
....
ois.readObject();
}
}
调用
ois.readObject();
将为MyWarMember抛出ClassNotFoundException:java.lang.ClassNotFoundException: my.war.MyWarMember from [Module "deployment.myear.ear:main" from Service Module Loader]
您将如何解决?谢谢!
最佳答案
您已经在my-war.war
和普通jar my-common.jar
之间创建了循环依赖关系。
从MyWarMember
您正在调用MyCommonMember.deepCopy(this);
-这将起作用,因为您已将jar添加到lib中
在MyCommomMember
中,您正在执行public static Object deepCopy(Serializable obj){
-未找到类异常,因为它不知道您在MyWarMember
中的my-war.war
。
解:
删除您的循环依赖项。
希望能帮助到你。