我的操作系统是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为什么会出现此错误?我很困惑。如何解决这个问题?
谢谢
最佳答案
我按照以下步骤解决了此问题:
打开位于module.xml
目录中的JDK的modules/system/layers/base/sun/jdk/main
。
在路径元素下包括以下3行:
<path name="com/sun/rowset"/>
<path name="com/sun/rowset/internal"/>
<path name="com/sun/rowset/providers"/>
保存
module.xml
重新启动Wildfly
不知道为什么Wildfly JDK模块还没有附带这3行。