This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Trouble setting up Hibernate with Struts in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Trouble setting up Hibernate with Struts in Eclipse" Watch "Trouble setting up Hibernate with Struts in Eclipse" New topic

Trouble setting up Hibernate with Struts in Eclipse

Rory Thomas

Joined: Apr 17, 2008
Posts: 27
Eclipse 3.4 (Ganymede)
Struts 1.3.8
Hibernate 3.3.1.GA
Tomcat 5.5
JDK 1.6 (although compiling as 1.5)

Working in Eclipse for about 5 months, and with Struts in Eclipse for about 2 months. I feel good about my understanding of how these work together. I have a working Struts webapp searching a table and returning results. Before I begin adding functionality to this app, I decided I should incorporate Hibernate to handle the database activity. That said, I really just want to plug it into Eclipse and go. This is where I run into the issues. I have been trying to get this running for about 20 hours now, and am getting to the end of my rope.

I have downloaded the hibernate-distribution-3.3.1.GA, and added hibernate3.jar to the WEB-INF/lib folder in my project. This means it is part of the classpath for this project. I have also added it directly to the Tomcat 5.5/common.lib folder, as I read this somewhere along the way. I was concerned about a conflict there, but it doesn't seem to be an issue. I had also downloaded the Hibernate Tools, but don't really think those are an issue either.

I hate to include so much code here, but hopefully it might shed light on my situation. Within my existing Dynamic Web Project (Struts), I have the following files (among other previously existing java files): (package is com.rorycullen)



In addition, within the com.rorycullen package, I have a test program borrowed from Rose India Tutorial, with code changed for my data:

1. When I run the HibernateTest1 "As Java Application" in Eclipse, I get:
Exception in thread "main" java.lang.NullPointerException
at com.rorycullen.HibernateTest1.main(
this happens in the flush()

2. When I comment out the last two lines of code, I get this:
Exception in thread "main" java.lang.NoSuchFieldError: name
at org.slf4j.impl.Log4jLoggerAdapter.<init>(
at org.slf4j.impl.Log4jLoggerFactory.getLogger(
at org.slf4j.LoggerFactory.getLogger(
at org.hibernate.cfg.Configuration.<clinit>(
at com.rorycullen.HibernateTest1.main(

I have tried a lot of changes here, and researched all over the web for ideas. I have messed around with the slf4j jars in many different ways, with no luck.

My build path includes:
src folder
junit folder
Apache Tomcat (related jars)
JRE System Library
WebApp Libraries (what is in WEB_INF/lib)
  • antlr-2.7.2.jar
  • commons-beanutils
  • commons-chain
  • commons-collections
  • commons-digester
  • commons-logging
  • commons-validator
  • dom4j
  • hibernate3
  • hibernate-testing
  • javassist
  • jstl
  • jta
  • log4j
  • mysql-connector
  • oro
  • slf4j-api
  • slf4j-log4j12
  • standard
  • struts-core-1.3.8
  • struts-taglib
  • struts-tiles

  • One thing that I was able to run was a copy of the Rose India Hibernate tutorial, which I downloaded as a zip file and copied into a new generic Java Project. I was able to run this successfully, in that it at least did what it should (to the point where the code is flawed, but it did set up three new tables in my database, using However, this zip came with all of the jars already embedded, with a lot more that I believe I need. I did try setting up a new Struts project and copying in all of the Rose India jars to the WEB-INF/lib, but I was not able to run the code there.

    Sorry for writing so much, I hope someone has solved this problem before and can offer some assistance. I'll keep working on it and see what I can do.

    (Seems to be log-related, but I have been able to solve the riddle!)


    SCJP February 2010, SCJA June 2008
    sudeep prasad

    Joined: Apr 05, 2011
    Posts: 8

    I am facing similar problem... I copied the hibernate project from Rose India it is working fine... But i cannot create a new hibernate project in my eclipse... I have installed hibernate plugin through j boss can any one help me in this regard... If i try to create a new project in hibernate perspective it allows me to create only configuration files but not the java packages or java classes

    rocket mass heater kickstarter
    subject: Trouble setting up Hibernate with Struts in Eclipse