我打包了一个 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]
你会如何解决这个问题?谢谢!