java为什么Wildfly中com/sun/rowset/CachedRowSetImpl的NoClassDefFoundError会出错?
我的操作系统是Windows 7 64位。我正在与Eclipse Luna合作。我正在探索从JBoss4.2.3到Wildfly 8.2.1的迁移
我创建了一个简单的web应用程序来测试com。太阳行集。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,并在服务器中获得正确的输出。日志:
AppContextListener: after create: rsa=com.srh.util.RowSetAdaptor@2a9073ef
将同一应用程序部署到Wildfly 8.2.1,并在服务器中获取NoClassDefFoundError。CachedRowSetImpl的日志:
Caused by: java.lang.NoClassDefFoundError: com/sun/rowset/CachedRowSetImpl
自从com。太阳行集。CachedRowSetImpl是JDK的一部分,那么为什么Wildfly会给出这个错误呢?我很困惑。如何解决这个问题
谢谢
# 1 楼答案
我按照以下步骤解决此问题:
打开位于
modules/system/layers/base/sun/jdk/main
目录中的JDK的module.xml
在“路径”元素下包括以下3行:
保存
module.xml
重新启动Wildfly
不知道为什么Wildfly JDK模块没有这3行代码