2 Replies Latest reply on Mar 11, 2009 6:26 AM by Bastian Brandt

    Using JPA in custom application type - classloading issue

    Bastian Brandt Newbie


      hope this is the right forum.

      I wrote some deployers to deploy applications packaged in a jar and described by a row of xml files. Deployment and undeployment works very well. When I change the code and redeploy the application the classes are reloaded correctly.

      Now I would like to use jpa in the application. I included a persistence.xml file into the jars META-INF and specified that the EntityManagerFactory should be bound to the global jndi namespace, to be able to access it out of the application.

      When I deploy the first time everything works fine. I can persist objects using JPA. But when I redeploy the application I get an exception:

      java.lang.IllegalArgumentException: object is not an instance of declaring class

      while trying to persist an object.

      Seemingly the TransactionManager is using still the old classloader which loaded the classes for the first deployment, while my application uses the new classloader.

      I think I have to pass hibernate the new classloader somehow.

      I am looking for some hints for how I could solve the problem.