Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Stripersist.getEntityManager().persist(client); on my daoImplementation is giving me a nullPointer
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where's the stack trace?
 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, my entityManager is null, but I'm not sure how to initialise it

Thanks

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic