gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 08:47:35 29 4
gpt4 key购买 nike

我的操作系统是 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com