8 Replies Latest reply on May 6, 2009 4:32 AM by ezani abdul halim

    Which folder does hibernate.jar, hibernate-annotations.jar,

    ezani abdul halim Newbie

      Hi there

      I am using Hibernate with JBoss 4.2.2GA and JDK5 Release11. I am using a collection of Hibernate jars which include hibernate.jar, hibernate-annotations.jar, hibernate-common-annotations.jar, hibernate-entitymanager.jar and hibernate-validator.java.

      I am unsure where to save all these Hibernate jar files.

      Do I save them in jboss-4.2.2.GA/server/default/lib -or- jboss-4.2.2.GA/lib -or- jboss-4.2.2.GA/client or jdk1.5.0_14\lib -or- jdk1.5.0_14jre\lib and why ?

      Many thanks for your help!

        • 1. Re: Which folder does hibernate.jar, hibernate-annotations.j
          jaikiran pai Master

          Ideally, you package those jars within your application. Any reason why you want to overwrite the ones in JBossAS?

          • 2. Re: Which folder does hibernate.jar, hibernate-annotations.j
            ezani abdul halim Newbie

            Hi

            What do you mean 'package those jars within your application' ?

            Do you mean in the application project folder of my workspace folder ? I do not see any lib folders there!

            Please give me a full directory or folder path if, say, my application name is 'Project1' and my workspace is : C:\workspace.

            Many thanks for your help!

            • 3. Re: Which folder does hibernate.jar, hibernate-annotations.j
              jaikiran pai Master

              Hmmm, so you are using an IDE. Which one are you using? I personally don't use an IDE for packaging, so won't be able to help much. Someone else with the IDE experience might be able to help.

              What do you mean 'package those jars within your application' ?


              Assuming you have a ear file, then here's how i would package my application to include the hibernate jars (and other libraries):
              myapp.ear
              |
              |--- META-INF
              | |
              | |--- application.xml
              | |--- jboss-app.xml
              |
              |
              |--- lib
              | |
              | |--- hibernatexxx.jar
              | |--- other jars
              |
              |
              |--- myapp.war


              • 4. Re: Which folder does hibernate.jar, hibernate-annotations.j
                ezani abdul halim Newbie

                Oh dear..dear...

                Ok, first thing is that I am using Eclipse Ganymede.

                I must be doing someting terribly wrong here. So far as I have understood, I have "physically" copied all those hibernate jar files from their respective setup folders to the jboss server default lib. Not so long ago I was unable to deploy my EJB3 JPA entity program because I was not using the Hibernate compatibility matrix to ensure correct versions. I copied all the appropriate hibernate jars (hibernate-distribution.3.3.jar, hibernate-common-annotations.3.4.jar, hibernate-annotations.3.4.jar, hibernate-entitymanager.jar and hibernate-validator.3.4.jar to the jboss server default lib and everything works.

                Also I must add that the ear files are also saved in the jboss server default deploy and sar and esb files are also saved here.

                I usually get confused by the Eclipse Package Explorer structure within the IDE and Windows Explorer as they have similar file structure (the same when it comes to the java projects).

                All I know is that when you get the hibernate distributions.zip (or gz.tar) or the hibernate entity manager and annotation zip or tar files, they will expand by default to their own folder with the same name as the product (e.g. C:\hibernate-entitymanager.3.4.0). Within these you can find the core jar file you need and any accompanying jars in the lib sub-folder.

                I just copy them all physically in Windows Explorer to jboss.4.2.2.GA\server\default\lib.

                Is this the right way to do it ? Or do I copy it into the clipse Package Explorer lib folder ? If so, where physically in the Windows file system will these files be kept ?

                Many thks for your assistance.

                • 5. Re: Which folder does hibernate.jar, hibernate-annotations.j
                  jaikiran pai Master

                   

                  I just copy them all physically in Windows Explorer to jboss.4.2.2.GA\server\default\lib.


                  Changing anything in the server's lib folder is very risky. That folder is meant for the server's (required) jar files. If you need different versions of the same jars (like Hibernate) in your application then as i said the correct place is to package (i.e. copy) them within the application. Let's wait for someone with IDE experience to tell how this can be done from an IDE.


                  • 6. Re: Which folder does hibernate.jar, hibernate-annotations.j
                    ezani abdul halim Newbie

                    Many thanks, Jaikiran! I still remember you helping me out with my EJB3 JPA app the last time. BTW what IDE do you use ? You have not used Eclipse before ? How do you do your Java/JEE programming then ? Actually looking at the many forum replies I have received from the JBoss and Hibernate sites, many of the posters do recommend copying files to the JBoss server libraries - for example, if there is a later version or for ClassNotFound exceptions.

                    Is there anyone with Eclipse experience who can help me out ? Many thks in advance!

                    • 7. Re: Which folder does hibernate.jar, hibernate-annotations.j
                      jaikiran pai Master

                       

                      "ezanih" wrote:
                      BTW what IDE do you use ? You have not used Eclipse before ? How do you do your Java/JEE programming then ?

                      I do use Eclipse, but just as a plain code editor. I don't use it (or any other plugins) for packaging the application or deploying to the server :) I use Ant (or other build tools) to do the packaging stuff.

                      "ezanih" wrote:

                      Actually looking at the many forum replies I have received from the JBoss and Hibernate sites, many of the posters do recommend copying files to the JBoss server libraries - for example, if there is a later version or for ClassNotFound exceptions.

                      That's an easy way out, but is risky since you are changing the jar versions on which the server was tested and shipped. And if other applications on the same server rely on the previous versions, then there's no way those applications will work.



                      • 8. Re: Which folder does hibernate.jar, hibernate-annotations.j
                        ezani abdul halim Newbie

                        Jaikiran:

                        Many thanks !!! I cannot thank you enough !!! Thank you !!! Thank you !!! Thank you !!!

                        I just realized that up till today, I have been WRONGLY copying all the physical files and messing up my JBoss AS server's libraries. Unbelievable!!! I cannot believe how I ended up in this mess and yet got my programs to work thus far by physically copying the files !!!

                        You are absolutely right !!! The best way is to create a lib folder within Eclipse and copy and paste directly any library or jar files you may need through the Package Explorer IDE.

                        What happens is that Eclipse will create that lib folder I just created within the Eclipse IDE physically into the Windows file system under the Eclipse workspace and in your relevant application's project folder. So for example you would have all your library files in a folder like this : C:\MyEclipseWorkspace\MyJavaProject\lib.

                        It can be very confusing ... yes, it can be. I mean, how many lib folders can you see in a typical Java programmer's PC. There's one in the JDK, one the JRE, two lib folders in the JBoss AS server directory and also one lib folder each Hibernate package you download. There are also many common files with the same names splattered everywhere...such as javaassist.jar (there's one in JBoss and one in the JDK.1.5.0_14). Also one can be confused with where to save ojcbd14.jar, for example.

                        With respect to ojcbd14.jar, if I installed my Oracle client and it saved ojcbd14.jar in Folder A, what would happen if I get an updated version of Oracle (for example 11)? The same with my Hibernate packages I downloaded. What do I do with all the zip and gz.tar files? I have to uncompress and expand them to some folder. So if I want to use hibernate-entitymanager-3.4.0.jar, for example, is it correct do download hibernate-entitymanager-3.4.0.zip from the Hibernate download site and then expand it to C:\hibernate-entitymanager-3.4.0 and then copy the resulting hibernate-entitymanager.jar into my lib folder within Eclipse? I think that's probably the way so that hibernate-entitymanager.jar would be copied into my project's lib folder and not affect others. I guess the downside is there will be a lot of duplicate files for each project setup. I thought just copying the most updated jar ONLY ONCE to the JBoss\server\lib folder would suffice to serve all the Java apps I create which uses JBoss. I was wrong. Anyway, I will have to try to adapt to this new habit right away. Thanks once again!