6 Replies Latest reply on Mar 27, 2008 6:49 PM by Shibu Gope

    why nobody talks openJPA here?

    mr662 Newbie

      Hello all,

      I am trying to port an application from weblogic to jboss AS 4.2.2. My application uses JPA and I was using OpenJPA as the persistence provider in weblogic.

      I don't see too much discussion here about openJPA and was wondering if anyone has tried using openJPA with jboss successfully and whether it works.

      I quickly tried to use hibernate as the persistence provider and am running into an Exception "org.hibernate.MappingException: Unable to find column with logical name userid in table userContact", where userid is the mapped column name for a ManyToOne relation. This code works fine with openJPA in both weblogic and websphere. Since I want to keep the code base same for this application for all 3 platforms (weblogic, websphere, jboss), I am inclined to use openJPA.

      I will try it next week. Just that I could not find any relevant document and lack of discussion here makes me little nervous.

        • 1. Re: why nobody talks openJPA here?
          Shibu Gope Newbie

          I don't think openJPA is recommended to use with JBoss and it is not supported by JBoss either.

          I personally started off my project with openJPA and I ran into problems (see my post - help needed with openJPA and JBoss)

          To help you with your problem, I assume you are talking of a bidirectional relationship, this is how I set it up in hibernate and it works smooth:

          Address_Detail - > * - 1 -> Address

          @ManyToOne(optional = false, cascade = { CascadeType.PERSIST, CascadeType.REFRESH })
          @JoinColumn(name = "ADDRESS_ID", nullable = false)
          private Address address;

          and in address, the definition is

          @OneToMany(mappedBy = "address", cascade = { CascadeType.ALL })
          private Collection addressDetails;

          • 2. Re: why nobody talks openJPA here?
            mr662 Newbie

            Thanks nitros. I thought I will give it a try anyway to see exactly what the issues are. I added the openJPA jars (all of them) to server/lib. But when I deploy my jar containing the entities and persistence.xml, I see following error:

            ObjectName: persistence.units:unitName=covApiSession
             State: FAILED
             Reason: java.lang.ClassNotFoundException: No ClassLoaders found for: org.apache.openjpa.persistence.PersistenceProviderImpl



            This is very strange since all the openJPA jars are in sever/lib dir and I did restart the server. I must be doing something very silly...

            • 3. Re: why nobody talks openJPA here?
              Shibu Gope Newbie

              I had the same issue and that's where I abandoned using openJPA as I
              didn't get much support from JBoss forums. Please check out the link
              below:

              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=130411

              Check out the persistence.xml I have in this thread.

              • 4. Re: why nobody talks openJPA here?
                mr662 Newbie

                When I deploy the whole ear, above issue goes away. However since I use MDB in my application, I am running into this issue

                http://jira.jboss.com/jira/browse/JBAS-5049

                Somebody has posted a patch here

                http://www.techienuggets.com/commentList.jsp?tx=18328&tx=18328&d-49653-p=1


                I am now debating the 3 options to proceed to next step; go back to 4.2.1, try patch or try 5.0.0 beta 4

                • 5. Re: why nobody talks openJPA here?
                  mr662 Newbie

                  Let me wrap up my findings for the benefit of others.

                  I ended up using Hibernate.

                  With 0.9.7 openjpa, i ran into the error that others have experienced too:

                  org.apache.openjpa.persistence.PersistenceException: Invalid use of
                  destroyed classloader, UCL destroyed at:


                  With 1.0 openjpa, my application came up ok but I saw all kinds of strange runtime errors.

                  So I gave up on openjpa and switched to hibernate.

                  But switching to Hibernate was not all that straight forward. It seems there are some inconsistencies between hibernate and openjpa when it comes to @IdClass. The two that I faced were :

                  1) Hibernate picks up the annotations from @IdClass, whereas openJPA picks up from the Entity class.

                  2) Hibernate needs both name and type of the id fields to be same in Entity class and IdClass, whereas OpenJPA wants type of the @ManyToOne field in the IdClass to be that of the primary key of the associated table.

                  Once I aligned my code to what hibernate wants, my application came up ok.

                  • 6. Re: why nobody talks openJPA here?
                    Shibu Gope Newbie

                    I very much agree. I stopped using openJPA for these reasons. But my hibernate use with JBoss is falwless so far.