I'm struggling with this error:
java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader
trying to run dynamic web application (in eclipse) using maven. There is a problem with hibernate and all the solutions don't seem to work. I'm using wildfly server. Here's the servlet:
public class HomeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
public static void main(String[] args) {
try {
Session session = DatabaseManager.getSession();
session.getTransaction().begin();
ArrayList<Book> books = (ArrayList<Book>)session.createCriteria(Book.class).list();
session.getTransaction().commit();
System.out.println(books.size());
} catch (IOException e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Session session = DatabaseManager.getSession();
session.getTransaction().begin();
ArrayList<Book> books = (ArrayList<Book>)session.createCriteria(Book.class).list();
session.getTransaction().commit();
System.out.println(books.size());
request.getRequestDispatcher("/home.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
If I run it as a normal java app (using main method) it works just fine. If I deploy it to the server I get
java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader
I assume that I should somehow set the libraries on the wildfly server but don't know how to do it. Any ideas?