Friday, March 2, 2012

Glassfish 3.1.2: Unable to load resource [com.mysql.jdbc.EscapeProcessor]

While I am building JEE6 web profile application, using EJB3.1, JPA2.1, JSF (IceFaces 3) against MySQL database v5.1.15, my java web app fails in Netbeans v7.1 when I try to run it.

Netbeans reports successful deployment, but then I get this error when executing a JPA query against MySQL:

java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [com.mysql.jdbc.EscapeProcessor], because it has not yet been started, or was already stopped.
This error occurs at the first query against the database. The entire application works fine with Netbeans version 7.1.
One potential clue is that I had to manually add the MySQL driver to the project for unit test the project using embedded glassfish 3.1.2.

After reviewing/tracing the problem and some googling about the problem here is the fix:

  1. For unit testing put the MySQL driver in the test libraries only don't add it to the project to final deployment.
  2. For production, the MySQL driver should not be in the project ... it should be in <DOMAIN>/lib/ext... in your glassfish v3.1.2 folder.
If there is any help just leave your comment.

4 comments :

  1. Hello,

    I have a project in NB 7.0. it works fine with GF 3.1.1, as soon as I installed 3.1.2 I get this exception - Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [com.mysql.jdbc.EscapeProcessor], because it has not yet been started, or was already stopped

    I added MySql connection jar in test libraries in NB but I still get this exception.

    Can you please help. Thanks.

    ReplyDelete
  2. Thank you, Mohamed! I put the connector lib in /lib/ext, and it worked like a charm!

    Mimi

    ReplyDelete
  3. Thanks dude! Fixed it for me 2

    ReplyDelete