日期:2014-05-19  浏览次数:21215 次

为何引入了org.dom4j.io.SAXReader,但在实例化时报错:java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader?
以下是我的程序的一部分:

package com.gd.mvc.util;
import java.io.File;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class GdParseXml {
  private Document document;

  private String path;
  private String action;
  private String forwardJsp;
  private String forwardJspPath;
  private String methodForwardJsp;
  private String actionName;
  private List voId=new ArrayList();
  private List voClass=new ArrayList();
  private List voType=new ArrayList();
  private String method;
  private String prefix;
  private String suffix;
 
  
  public void read(String fileName)throws MalformedURLException,DocumentException{
 
SAXReader reader=new SAXReader();
  document=reader.read(new File(fileName));
}

  当执行到SAXReader reader=new SAXReader()时报错:
  java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader
com.gd.mvc.util.GdParseXml.read(GdParseXml.java:33)
com.gd.mvc.servlet.GdServlet.do_Dispatcher(GdServlet.java:40)
com.gd.mvc.servlet.GdServlet.doPost(GdServlet.java:28)
com.gd.mvc.servlet.GdServlet.doGet(GdServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

哪位大侠可以指教这是为什么啊?!!

------解决方案--------------------
NoClassDefFoundError: org/dom4j/io/SAXReader
不是很明显么
你lib里没有这个jar包吧

------解决方案--------------------
/WebRoot/WEB-INF/lib