• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Help with JPA

 
Ranch Hand
Posts: 185
Netbeans IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

can someone with JPA experience PLEASE help me. All I want to do is persist an entity to a database. Sounds easy yes? I have been trying for two weeks solid now to persist a simple Persons class to a database with a table called persons with an id, firstName and age field. I have asked in many java forums but come up with the same answers, which don't help. I am trying to use a container injected EJB for the work. I am using netbeans (comes with glassfish 3.1.1). I can read from the database no problem but I keep getting a null pointer exception when I try to persist to it. I have a simple jsp page with a form that takes the users first name and age, when they hit submit I want to store it in a database.

My servlets POST method which takes the users info and send the object to be persisted (I have the PersonsFacace object injected as an EJB at the top of the class i.e. @EJB private PersonsFacade pf):

The PersonsFacade class generated by netbeans "create session from entiy classes" wizard and its associated abstract facade:

The entity class:

My persistence.xml file:


I know that the entity manager in the person facade class is not meant to be instantiated because it is injected by the container so I am at a loss to why I am getting a null pointer exception.

Any help would be greatly appreciated!

Thanks,
Alan
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please include the null-pointer exception stack trace.
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic