Using: Eclipse 3.4 (Ganymede) Struts 1.3.8 Hibernate 3.3.1.GA MySQL 5 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): com.rorycullen.BeerBean.java (package is com.rorycullen) BeerBean.hbm.xml hibernate.cfg.xml
In addition, within the com.rorycullen package, I have a test program borrowed from Rose India Tutorial, with code changed for my data:
Issues: 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(HibernateTest1.java:37) 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>(Log4jLoggerAdapter.java:75) at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151) at com.rorycullen.HibernateTest1.main(HibernateTest1.java:22)
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 mysql-connector...jar Apache Tomcat (related jars) JRE System Library WebApp Libraries (what is in WEB_INF/lib)
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 FirstExample.java). 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!)
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