java - 为什么在 Wildfly 中 com/sun/rowset/CachedRowSetImpl 出现 NoClassDefFoundError?

标签 java jboss wildfly cachedrowset

我的操作系统是 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: after create: rsa=com.srh.util.RowSetAdaptor@2a9073ef

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

Caused by: java.lang.NoClassDefFoundError: com/sun/rowset/CachedRowSetImpl

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

谢谢

最佳答案

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

打开位于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 JDK 模块没有附带这 3 行。

关于java - 为什么在 Wildfly 中 com/sun/rowset/CachedRowSetImpl 出现 NoClassDefFoundError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32382354/

相关文章:

java - 使用 byte、short 和其他基本类型

java - gridView - strings.xml 中的数组

java - Spring 启动 Spring 安全AngularJS

java - 将 WAR 分配给 JBOSS 中的安全域

java - 我的服务器需要什么来支持 java webprojects?

docker - 为什么 OpenJDK Docker 容器会忽略 Kubernetes 中的内存限制?

java - redis.clients.jedis.exceptions.JedisConnectionException : java.net.UnknownHostException

java - 我在哪里可以找到实现 servlet 规范 12.1 和 12.2 的 JBoss 源代码?

Eclipse Neon + JBossTools + Maven 结果出现错误 : No compiler is provided in this environment

java - 无法查找 JNDI 名称 [javax.transaction.TransactionManager]