Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Upgrading to a new version of Hibernate under Eclipse

 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Copy the mvn_home/conf/settings.xml file to user_home/.m2/settings.xml and uncomment the local-repository entry.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic