0

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?

Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49
Charlie B
  • 303
  • 1
  • 4
  • 12

1 Answers1

0

There is a problem same as you, when deploying ,please make sure you have all the dependency libs. Caused by: java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader

Community
  • 1
  • 1
dawnfly
  • 93
  • 2
  • Yeah, this is like the first result in google when you type some words from the title of this problem, and guess what- I've been there, not working. – Charlie B May 21 '17 at 15:24