12 Replies Latest reply on Jul 14, 2009 3:29 AM by tony.herstell1

    Seam 2.2.0.CR1 and Hibernate and Ear deployment.

    tony.herstell1

      In the lib area of the seam download there used to be a hibernate.jar.


      This is no longer present in 2.2.0.CR1.


      I now see various hiberante jars. (core, entitymanager, validator etc.).


      Which ones should I use and should they be added to the EAR (application.xml)
        or
      Should they be added to the Jar and be added to the build path (BuildPath - Add To Build Path).


      I have to have hibernate-validator.jar added to Jar build path as I call it and I have a compile problem in the IDE without it!.



      InvalidValue[] invalidValues = Validators.instance().getValidator(MailingListEntry.class).getPotentialInvalidValues("email", email);




      I notice 2 things...


      1. I can launch with JUST hibernate-validator.jar in the jar onto Jboss-4.2.1.GA and all still works but I think that Jboss may actually ship with hibernate so its picking up an old version... In startup I see:



      19:18:51,565 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=Sec.ear,jar=SecEJB.jar,unitName=secDatabase
      19:18:51,596 INFO  [Version] Hibernate EntityManager 3.2.1.GA
      19:18:51,627 INFO  [Version] Hibernate Annotations 3.2.1.GA
      19:18:51,643 INFO  [Environment] Hibernate 3.2.4.sp1
      19:18:51,643 INFO  [Environment] hibernate.properties not found




      2. Looking round examples (useful for building an Ear and cracking it to see what should be deployed) I found that the wiki example has hiberante3.jar.


      Quite confusing!

        • 1. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
          tony.herstell1
          • 2. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
            cjalmeida

            The hibernate jars are used by JBoss in order to do ejb3 deployment. If you can afford, it's better to replace jboss/server/config/lib/[hibernate*.jar,ejb3-persistence.jar] with the ones in your project's lib.


            I always got burned when puting hibernate's jar inside the EAR.


            • 3. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
              tony.herstell1

              Welcome to red belt java.


              http://www.jboss.org/community/wiki/jbossclassloadingusecases


              Now all I got to do is really understand it!

              • 4. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                tony.herstell1

                Still trying to figure this out...

                • 5. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                  swd847

                  I package my hibernate jars and all dependencies (slfj,javassist etc) inside the ear. According to the console output the correct hibernate version gets used. You need to make sure you are using isolated classloading:


                  
                  <jboss-app>
                     <loader-repository>
                        seam.jboss.org:loader=@PROJECTNAME@.ear
                        <loader-repository-config>
                             java2ParentDelegation=false
                        </loader-repository-config>
                     </loader-repository>
                  </jboss-app>
                  

                  • 6. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                    tony.herstell1

                    Cheers,
                    And er... which of the hibernate files are now required?
                    It PROBABLY used to be hibernateall but now it's a whole myriad of them.
                    Worringly IDE seems not to care to much if they are there!



                    • 7. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                      swd847

                      For the actual build process you can probably get by with your old hibernate jar, as long as you don't use any API's that have changed. I just bendle all of them


                      
                      
                          <module>
                              <java>javassist.jar</java>
                          </module>
                      
                          <module>
                              <java>hibernate-annotations.jar</java>
                          </module>
                          <module>
                              <java>hibernate-commons-annotations.jar</java>
                          </module>
                          <module>
                              <java>hibernate-validator.jar</java>
                          </module>
                      
                          <module>
                              <java>hibernate3.jar</java>
                          </module>
                      
                          <module>
                              <java>hibernate-entitymanager.jar</java>
                          </module>
                          <module>
                              <java>slf4j-api-1.5.2.jar</java>
                          </module>
                      
                          <module>
                              <java>slf4j-log4j12-1.5.2.jar</java>
                          </module>
                      
                      
                      



                      • 8. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                        tony.herstell1

                        Thanks Stuart:


                           In the lib area of the seam download there used to be a hibernate.jar


                           This is no longer present in 2.2.0.CR1.


                           I now see various hiberante jars. (core, entitymanager, validator etc.).

                        • 9. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                          tony.herstell1

                          Also I don't have any kind of build process.
                          Use MyEclipse and exploded deployment to develop in (really really fast!).
                          So if the IDE cant figure it out... then there cant be a dependence to my code (humm..)

                          • 10. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                            tony.herstell1


                            <?xml version="1.0" encoding="UTF-8"?>
                            <application xmlns="http://java.sun.com/xml/ns/javaee"
                                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
                                    version="5">
                            
                                    <display-name>SEC</display-name>
                            
                                    <module>
                                            <web>
                                                    <web-uri>SecWeb.war</web-uri>
                                                    <context-root>/site</context-root>
                                            </web>
                                    </module>
                            
                                    <module>
                                            <ejb>SecEJB.jar</ejb>
                                    </module>
                            
                                    <module>
                                            <ejb>jboss-seam.jar</ejb>
                                    </module>
                            
                                    <module>
                                            <java>jboss-el.jar</java>
                                    </module>
                                    
                                    <module>
                                            <java>richfaces-api-3.3.2-20090526.040422-5.jar</java>
                                    </module>
                                    
                            </application>




                            • 11. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                              swd847

                              Myeclipse would have hibernate somewhere on it's build classpath. As long as you are not using's hibernate API's that change between versions it is possible to build against one version and deploy against another (although if you do use a changed API you will get class loading errors, so it is not the best idea).



                              At deployment time AFAIK you need the new hibernate, so you have three options:


                              1) Upgrade to a newer jboss that comes with a newer hibernate
                              2) upgrade the hibernate libs in your current jboss
                              3) bundle hibernate in your ear.

                              • 12. Re: Seam 2.2.0.CR1 and Hibernate and Ear deployment.
                                tony.herstell1

                                Hi Stuart,


                                Thanks for support.


                                Will go option 3 but not sure what Libs I need from the hibernate bunch (just will have to experiment to find out... as no info in new Seam release notes (other than to say the version of hibernate changed)).


                                So will the take hib jar out of Jar project and put in Ear Project, add others, and alter application.xml (as above).


                                Will do a little research on MyEclipse and see how to override (ignore) their default ones.


                                Will have to add this (below) somewhere (I hope its also in projects application.xml) as apposed to the server.xml as then I can make change as apposed to all the team having to update their obscure machines (Mac, PAC, Linux etc.)!


                                <jboss-app>
                                   <loader-repository>
                                      seam.jboss.org:loader=@PROJECTNAME@.ear
                                      <loader-repository-config>
                                        java2ParentDelegation=false
                                      </loader-repository-config>
                                   </loader-repository>
                                </jboss-app>




                                Then will see what effects it has.


                                Cheers.