0

我在 JBoss 中部署了一个简单的 maven WAR 项目。该项目依赖于另一个 jar (J1),而 J1 又依赖于其他 jar 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;
   }
 }
4

0 回答 0