![](/img/trans.png)
[英]java.lang.ClassNotFoundException: com.sun.rowset.CachedRowSetImpl in wildfly-9.0.2.Final
[英]Why NoClassDefFoundError for com/sun/rowset/CachedRowSetImpl in Wildfly?
我的操作系統是 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 會出現此錯誤? 我很迷惑。 如何解決這個問題?
謝謝
我按照以下步驟解決了這個問題:
打開位於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 行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.