1 Replies - 5730 Views - Last Post: 15 July 2012 - 11:16 AM

#1 stayfierce  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 02-December 09

javax.persistence.PersistenceException: java.lang.NullPointerException

Posted 10 July 2012 - 10:51 AM

Good Afternoon,

I am new to working with JPA and I am using the Oracle "Trouble Ticket System" Tutorial (Step1). Here is the actual tutorial:
Oracle Trouble Ticket System tutorial

Here is the following framework I am using:

Oracle Weblogic 12c
MySql 5.x
EclipseLink 2.0
JPA 2.0


Once I arrived at the very end of the tutorial, it required me to run several JUnit tests. But with no such luck, all of the test failed. I cannot seem to wrap my hands around why the test are failing. Currently, there are no errors in the project. I have tried to google for help and nothing is working. I also noticed that the error is very generic. It does not provide me with additional informationm, but only javax.persistence.PersistenceException: java.lang.NullPointerException. I am very lost.

Is there something missing from my build path?
Is there something I need to configure in Properties > JPA?
Is there something with my Data Source (persistence.xml)?


Please find below the stack trace:

javax.persistence.PersistenceException: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
	at com.oracle.ticketsystem.dao.impl.JPADaoFactory.createEntityManager(JPADaoFactory.java:31)
	at com.oracle.ticketsystem.dao.impl.BaseJPADao.getEntityManager(BaseJPADao.java:12)
	at com.oracle.ticketsystem.dao.impl.TicketJPADao.add(TicketJPADao.java:35)
	at com.oracle.ticketsystem.dao.tests.TicketDaoTest.testAdd(TicketDaoTest.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
	at java.util.ResourceBundle.getBundle(ResourceBundle.java:950)
	at org.eclipse.persistence.exceptions.i18n.ExceptionMessageGenerator.buildMessage(ExceptionMessageGenerator.java:47)
	at org.eclipse.persistence.exceptions.ValidationException.errorDecryptingPassword(ValidationException.java:868)
	at org.eclipse.persistence.internal.security.JCEEncryptor.decryptPassword(JCEEncryptor.java:124)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateLogins(EntityManagerSetupImpl.java:1589)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:1892)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:471)




I have also attached the BaseJPADao, JPADaoFactory, and the files associated with one of the JUnit test I was trying to run.

Thank you in advance for you help and assistance.

Best regards,

stayfierce

Attached File(s)


This post has been edited by stayfierce: 10 July 2012 - 10:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: javax.persistence.PersistenceException: java.lang.NullPointerException

#2 RCR  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 33
  • Joined: 04-July 12

Re: javax.persistence.PersistenceException: java.lang.NullPointerException

Posted 15 July 2012 - 11:16 AM

Maybe one of your reference variables has not been initialized, and that is why you are getting a Null Pointer Exception.

When you declare a reference to a variable(mostly objects in Java) you are pointing to the object. So a reference is really a pointer to a value. Look at this example:

int q;
q = 1;


Even though this is a primitive value, it is still a pointer, but not to another object, to memory. The life cycle of our int q is the following:
q is born, and has no value(0);
q is a reference to the value 1;

In summary the difference between the two is that a reference is a pointer, and a primitive is a data type, so it points directly to memory.

This example shows a Null Pointer Exception:

public void someMethod(Object o) {
o.something();
/*........*/



Don't worry about your build path or that Persistence Exception, I would try to track down the Null Pointer Exception before worrying about any of them, because it is probably the cause of all the others.

- RCR

This post has been edited by RCR: 15 July 2012 - 11:18 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1