【问题标题】:Why NoClassDefFoundError for com/sun/rowset/CachedRowSetImpl in Wildfly?为什么在 Wildfly 中 com/sun/rowset/CachedRowSetImpl 出现 NoClassDefFoundError?
【发布时间】:2015-09-03 17:51:26
【问题描述】:

我的操作系统是 Windows 7 64 位。我正在使用 Eclipse Luna。我正在探索从 JBoss 4.2.3 迁移到 Wildfly 8.2.1。

我创建了一个简单的 Web 应用程序来测试 com.sun.rowset.CachedRowSetImpl,我认为它是 JDK 的一部分。

我创建了一个类 RowSetAdaptor 作为 CachedRowSetImpl 类的包装器:

package com.srh.util;

import java.io.Serializable;
import java.sql.SQLException;
import com.sun.rowset.CachedRowSetImpl;

public class RowSetAdaptor implements Serializable {
   private CachedRowSetImpl rowset;
   public RowSetAdaptor() {
      try {
         rowset = new CachedRowSetImpl();
      } catch (SQLException sqle) {
         System.out.println("RowSetAdaptor: constructor: SQLException=" + sqle);            
      }     
   }
}

然后我创建一个监听类AppContextListener

package com.srh.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import com.srh.util.RowSetAdaptor;

public class AppContextListener implements ServletContextListener {
    public AppContextListener() {
    }

    public void contextInitialized(ServletContextEvent arg0) {
        RowSetAdaptor rsa = null;
        rsa = new RowSetAdaptor();
        System.out.println("AppContextListener: after create: rsa=" + rsa);
    }

    public void contextDestroyed(ServletContextEvent arg0) {
    }
}

将应用部署到 Jboss 4.2.3 并在 server.log 中获得正确的输出:

AppContextListener:创建后: rsa=com.srh.util.RowSetAdaptor@2a9073ef

将相同的应用程序部署到 Wildfly 8.2.1 并在 server.log 中为 CachedRowSetImpl 获取 NoClassDefFoundError :

引起:java.lang.NoClassDefFoundError: com/sun/rowset/CachedRowSetImpl

既然 com.sun.rowset.CachedRowSetImpl 是 JDK 的一部分,那么为什么 Wildfly 会给出这个错误?我很困惑。如何解决这个问题?

谢谢

【问题讨论】:

    标签: java jboss wildfly cachedrowset


    【解决方案1】:

    我按照以下步骤解决了这个问题:

    打开位于modules/system/layers/base/sun/jdk/main目录下的JDK的module.xml

    在路径元素下包含这 3 行:

    <path name="com/sun/rowset"/>
    <path name="com/sun/rowset/internal"/>
    <path name="com/sun/rowset/providers"/>
    

    保存module.xml

    重启 Wildfly

    不知道为什么 Wildfly JDK 模块还没有这 3 行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 2020-03-16
      • 1970-01-01
      • 2012-09-15
      • 1970-01-01
      相关资源
      最近更新 更多