wood burning stoves 2.0*
The moose likes Other Application Frameworks and the fly likes Stripes, Spring, JPA, Hibernate, struggling to tie them all together Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Stripes, Spring, JPA, Hibernate, struggling to tie them all together" Watch "Stripes, Spring, JPA, Hibernate, struggling to tie them all together" New topic
Author

Stripes, Spring, JPA, Hibernate, struggling to tie them all together

James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Hi,

I've got an application with the above mentioned technologies, it seems to work great using a mock DAO to display my objects on the JSPs.

I've created a form pre-populated with some mock data, and I'm trying to persist this, but this is where I'm coming across a nullpointer and I have absolutely no idea why, I've followed lots of tutorials and have spent the whole day searching for an answer

ActionBean


Service


Dao Implementation


persistence.xml


In my MockDAO I return a list of my objects which I use to display on my JSPs, what I've done is setup a form pre-populated with one of those objects, then I'm clicking a "save" button which should (via the service) invoke the .persist() on that object.

I've got all my hibernate / HSQLDB jars etc on the classpath, but I haven't explicitly done anything with HSQLDB as I wasn't aware I need to

Where am I going wrong?


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

The Stripersist.getEntityManager().persist(client); on my daoImplementation is giving me a nullPointer
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Where's the stack trace?
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228



I've set breakpoints on the .persist() and the object that its trying to persist is there and valid, so that part shouldn't be causing the nullpointer

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Then I'd assume there's no entity manager, assuming that's why you included that bit of code. How does Stripes expect you to create that?
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

yeah, my entityManager is null, but I'm not sure how to initialise it

Thanks

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Stripersist should handle creating the entitymanager for you. There is an interceptor in the library that does this and opens and commits sessions for each page request. You'd probably be better off asking Stripersist specific questions on the Stripes mailing list since that is where the project author(s) hangs out.

Now, on for a very opinionated piece of information. You're already using Spring and Hibernate. I love Stripes. But considering your stack, I feel you'd be better off using Grails if you can. It uses Spring and Hibernate as well. It just makes things TONS easier.

GenRocket - Experts at Building Test Data
 
 
subject: Stripes, Spring, JPA, Hibernate, struggling to tie them all together
 
Similar Threads
Exception while getting transaction
Problem -EJB3+JPA+HIbernate
EntityManager returned as null in Java SE
Programatic Schema Export with Hibernate and EJB3
Problem whne used custom squence name in JPA (hibernate) annotations