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

    Using JPA in custom application type - classloading issue

      Hi,

      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.

      Thx

      Basti

        • 1. Re: Using JPA in custom application type - classloading issu
          jaikiran

          More details please:

          1) The exact JBossAS version
          2) The Java version and vendor
          3) Your deployers - the configuration and any relevant code
          4) The entire exception stacktrace and the code which does the persisting.

          • 2. Re: Using JPA in custom application type - classloading issu

            Thank you for your answer jaikiran.

            Unfortunately while cleaning up my code a bit, preparing a more detailed post, I realized that that the class reloading is not working. I always tested in debug mode and it was the debugger swapping in the new class definition :(. I was wondering anyway why it was working.

            Probably when the classreloading works the JPA problem will disapear.