aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Upgrading to a new version of Hibernate under Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Upgrading to a new version of Hibernate under Eclipse" Watch "Upgrading to a new version of Hibernate under Eclipse" New topic
Author

Upgrading to a new version of Hibernate under Eclipse

Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
Please don't RTFM me, I am under a deadline, I am not familiar with Maven and need to upgrade to a newer Hibernate (production version).

I downloaded all parts of Hibernate and unzipped them into a separate Hibernate Eclipse project. I did not rebuild it; just added all jars to the Java Build Path | Libraries at Hibernate project, then included the Hibernate project as a dependency at my application project. Surprisingly, that did not make any of those jars visible from the application project (even though they do appear at Order and Export of the Hibernate project.. hmm), so I had to repeat that step again at my application project.

Now the problem is more subtle, since different sub-projects of Hibernate (annotations-3.4.0.GA, distribution-3.3.2.GA, entitymanager-3.4.0.GA, search-3.1.1.GA, validator-3.1.0.GA), even though https://www.hibernate.org/6.html says they work together, seem to rely different versions of the dependent libraries.

At present, I am getting

java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

I have this class in the following jars in my Hibernate project:

annotatins-3.4.0.GA\lib\test\slf4j-log4j2.jar,
search-3.1.1.GA\dist\lib\slf4j-api-1.4.2.jar,

and some others, different versions apparently, so the order of classpath becomes important. When I do it by trial and error, I get a NonExistentField exception or something, which, again, tells me of version incompatibility with jars.

I don't want to do it by brute force, since there are just too many jars, and there has to be a straightforward way of doing it? Maybe based on Maven? Again, I don't know Maven, and no time to learn now.

Any suggestion would be greatly appreciated.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

Let me see if I understand this correctly. You are trying to use Eclipse to build a project that uses Hibernate and you are running into issues with convincing Eclipse to including all the necessary JAR files in classpath for the build. Is that a reasonable summary if the issue?

Yes. Maven will help solve this. So will Ant. But if you know neither and you are under a deadline...

I'm not sure what to tell you for the short term. I never rely on Eclipse to do my builds (except for the occasional simple toy app) because I don't like surprises. By doing all of my builds via Maven or Ant means I know exactly what I am getting.

One thing you might try: Install m2eclipse. Then create a new Maven project and add Hibernate to the dependencies. Then add you code to that project. Only add a JAR that Hibernate depends on if your code uses it directly. Then let Maven take care of the transitive dependencies.


JBoss In Action
Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
Peter Johnson wrote:One thing you might try: Install m2eclipse. Then create a new Maven project and add Hibernate to the dependencies. Then add you code to that project. Only add a JAR that Hibernate depends on if your code uses it directly. Then let Maven take care of the transitive dependencies.


Perfect. I'll try, thanks!
Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
How do you specify a custom repository directory? My C: drive is full. from reading mvn.bat, I figured that specifying a %HOME% variable would help.. it did not.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

Copy the mvn_home/conf/settings.xml file to user_home/.m2/settings.xml and uncomment the local-repository entry.
 
Don't get me started about those stupid light bulbs.
 
subject: Upgrading to a new version of Hibernate under Eclipse