aspose file tools*
The moose likes Spring and the fly likes Seeking simple Spring MVC + Hibernate + MySql + Tomcat  tutorial/working project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Seeking simple Spring MVC + Hibernate + MySql + Tomcat  tutorial/working project" Watch "Seeking simple Spring MVC + Hibernate + MySql + Tomcat  tutorial/working project" New topic
Author

Seeking simple Spring MVC + Hibernate + MySql + Tomcat tutorial/working project

Myke Enriq
Ranch Hand

Joined: Feb 13, 2012
Posts: 109
I have wasted the alst 3 days putting jar files in various tutorials , yet they do not work.

Spring 3 + Hibernate 4 + MySql + Tomcat + Eclipse Indigo = thsi is what I have on my computer


Can anyone please give me a project that works ? The best would be a tutorial so I can read the explanations too.

I know how to make a simple Spring / Hibernate application , but I do not know (have problems) combining them.

Can anyone please help ?
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1507
    
    5

Hi cod,

Welcome to coderanch!

There's a dedicated forum for Hibernate/Spring where you can get better help.

Secondly, this is NotACodeMill, so please post what have you tried till now, what you want to achieve, and exactly where you are facing an issue.

I hope this helps.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Anayonkar Shivalkar wrote:
There's a dedicated forum for Hibernate/Spring where you can get better help.

Thanks! moved it to the right forum.

Mohamed Sanaulla | My Blog
Myke Enriq
Ranch Hand

Joined: Feb 13, 2012
Posts: 109
So here is my exact problem: I learned how to make a simple Hibernate+MySQL class/table mapping , I also learned how to make a simple Spring MVC application.

- simple Hibernate mapping program = 1 hibernate.cfg.xml + 1 Mapped_class.xml + 1 mapped_class.java + 1 main.java + 1 returnSessionFactory.java class
- simple SPring MVC application = 1 web.xml + 1 dispatcher-servlet.xml + 1 controller.java + 1 page.jsp file

The thing is I want to make a simple SPring MVC application that uses Hibernate to map a class over a table and insert/delete CRUD system on that table.

How do I do that ?:

- first I cannot find a tutorial/example that actually works (with the jars of Spring 3/ Hibernate 4/ Eclipse Indigo/MySQL). Anyone know a new tutorial(tutorial for these versions of jars) ?

- wasted a ton of time trying to make some examples run by adding jars on them only to get compatibility issues. Anyone knows a working project ?

- how do I connect the web.xml with the hibernate.cfg.xml ? Is there a free tutorial explaining this ?

- what happen with the returnSessionFactory.java class ? In all SPringMVC + Hibernate tutorials I see this class does not exist , it is embedded in the web.xml or some other .xml file as the SessionFactory bean. Anywhere I can get more information on this (like how Spring links the beans) ?

Thank you for your answers and for your time , please help me if you can.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Unfortunately, to fully explain it all would take a lot of time. So I am going to just do the basics.

1) Do you understand Spring and Spring configuration?

If you do then this will make sense.

Basically to integrate Hibernate with Spring, and that also means a Spring MVC application. Is to configure and start Hibernate via Spring configuration.

To do that you basically create a <bean> where you use Spring's LocalSessionFactoryBean or AnnotationSessionFactoryBean class as the class="" part of the <bean> tag.

Then you just set that bean's properties. In this case, you don't need a hibernate.cfg.xml file anymore, all that configuration is now in that <bean> tag. That is typically how you integrate Hibernate in Spring. It is all documented in the Core Spring documentation. Under the data sections, right after jdbc. (FYI, you can also set a property of those FactoryBean classes to point to the hibernate.cfg.xml file)

Look at the section 13.3 Hibernate here for more info on the FactoryBean configuration.

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html

You can also have Spring automatically do a lot for you with Spring ROO.

Remember to check your private messages for that important message from us moderators.

Mark



Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Myke Enriq
Ranch Hand

Joined: Feb 13, 2012
Posts: 109
Ok , I wrote a simple SpringMVC+Hiberante example, wrote the xml to configure the MVC stuff and hibernate and sessionFactory , I added all the jars for it to run , but when I run it the following error appears:

exception:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.context.request.ServletRequestAttributes.updateAccessedAttributes()

root cause:

java.lang.NoSuchMethodError: org.springframework.web.context.request.ServletRequestAttributes.updateAccessedAttributes()



The thing is I searched bit on the web, the jars I added may not be compatible;
Here are the jars in my project , please tell me your opinion:

antlr-2.7.6
aopalliance-1.0
commons-collections-3.1
commons-dbcp-1.1
commons-logging-1.1.1
commons-pool-1.3
dom4j-1.6.1
hibernate-jpa-2.0-api-1.0.1
hibernate3
javassist-3.12.0
jta-1.1
mysql-connector-java-3.1.11
org.springframework.aop_3.0.5
org.springframework.asm_3.0.5
org.springframework.beans_3.0.5
org.springframework.context_3.0.5
org.springframework.context.support_3.0.5
org.springframework.core_3.0.5
org.springframework.expression_3.0.5
org.springframework.web_3.0.5
servlet-api
slf4j-api-1.6.1
spring-2.0-rc3
spring-dao-1.2
spring-hibernate3-2.0.3
spring-webmvc-3.0.5
Myke Enriq
Ranch Hand

Joined: Feb 13, 2012
Posts: 109
Anyone got any ideea on what jar are not compatibile here ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

All of these look suspect to me

spring-2.0-rc3
spring-dao-1.2
spring-hibernate3-2.0.3
spring-webmvc-3.0.5

But the easiest way to get the jars is to use something like maven or gradle and add the dependencies there like



The I just set the spring.version in the pom file to what version of Spring I want to use.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seeking simple Spring MVC + Hibernate + MySql + Tomcat tutorial/working project