• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Stripersist.getEntityManager().persist(client); on my daoImplementation is giving me a nullPointer
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where's the stack trace?
 
James Elsey
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah, my entityManager is null, but I'm not sure how to initialise it

Thanks

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic