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