我在JBoss中部署了一个简单的maven WAR项目。这个项目取决于另一个罐子(J1),而J1又取决于其他罐子J2和J3。
所以我在WAR的pom.xml中添加了J1,J2,J3依赖项,当我构建时,我可以看到WAR的lib文件夹中的所有jar。
当我的程序在JBoss中运行时,我在从J2加载类时遇到类加载异常,这是在J1类中导入的。
任何想法我们如何解决这个或可能是什么问题?我甚至尝试在我的WAR类中导入该类,但奇怪的是WAR类被正确加载并且流程移动到J1然后再次获得相同的异常。如果找不到类,我不应该在加载WAR类本身时遇到异常吗?
更新: 课程是这样的:
package com.zebra.jpos;
public class Loader extends ClassLoader
{
private Class c;
private Object o;
private String name;
public static final String version = "$Id: Loader.java,v 1.1.1.1 2006/08/03 15:05:19 qolson Exp $";
public Loader(String n)
throws ClassNotFoundException
{
this.o = null;
this.name = n;
try {
this.c = loadClass(this.name, true);
} catch (ClassNotFoundException e) {
throw e;
}
}
public Class theClass()
{
return this.c;
}
public Class loadClass(String name, boolean resolve) throws ClassNotFoundException
{
try {
this.c = findSystemClass(name);
} catch (ClassNotFoundException e) {
throw e;
}
return this.c; }
public Object NewInstance() {
try {
this.o = theClass().newInstance();
} catch (InstantiationException e1) {
return null;
} catch (IllegalAccessException e2) {
return null;
} catch (Exception e3) {
return null;
}
return this.o;
}
public static Object getInstance(String class_name) throws ClassNotFoundException {
Loader classloader;
try {
classloader = new Loader(class_name);
} catch (ClassNotFoundException e) {
throw e;
}
if (classloader != null) {
return classloader.NewInstance();
}
return null;
}
}