0

I imported a project into eclipse and added the dependenciues (Just oracle drivers and junit4). But when I try to run the project I get a ExceptionInInitializerError. I can't initialize certain variables for some reason.

I know the project is okay so I think it is a problem with the JDK.

I have tried goggling it but I didn't get any solution.

Any help would be greatly appreciated.

java.lang.ExceptionInInitializerError
at com.ats.dao.RetrievalDAO.<init>(RetrievalDAO.java:27)
at com.ats.dao.test.RetrievalDAOTest.testinsertmessage(RetrievalDAOTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
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.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.ats.util.Config.<init>(Config.java:17)
at com.ats.retriever.DBPropertiesRetriever.<clinit>(DBPropertiesRetriever.java:11)
... 25 more
5
  • This may not be JDK issue as you have exception in com.ats.dao.RetrievalDAO which is your project class. Can you add few line from this class including lile 27 and before Commented Oct 20, 2014 at 18:00
  • I think we might need to see some code. Can you please post the contents of RetrievalDAO.java around line 27 and also the constructor of com.ats.util.Config.java (around line 17)? Commented Oct 20, 2014 at 18:06
  • I know its not the project class , because its a shared repository and all the junit test are passing for everyone else. I also had this project running before, and there have not been any changes except that I had to manually set the JRE and other dependencies. I get the same error in every test null pointer exception at at java.util.Properties$LineReader.readLine(Unknown Source Commented Oct 20, 2014 at 18:07
  • Hey Just figured out what went wrong, I had folders that need to be added to the build path. *Faceplam. Thanks anyway Commented Oct 20, 2014 at 18:10
  • No worries, glad to hear you figured it out! :-) Commented Oct 20, 2014 at 18:11

1 Answer 1

2

Your stacktrace is telling you what you need to know. These lines:

java.lang.ExceptionInInitializerError
at com.ats.dao.RetrievalDAO.<init>(RetrievalDAO.java:27)
at com.ats.dao.test.RetrievalDAOTest.testinsertmessage(RetrievalDAOTest.java:49)
...

... tell you that your code is hitting an error in the constructor of the RetrievalDAO class while being run by the RetrievalDAOTest (presumably a unit test). The exception is further caused by:

Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.ats.util.Config.<init>(Config.java:17)
at com.ats.retriever.DBPropertiesRetriever.<clinit>(DBPropertiesRetriever.java:11)

... which tells you that the actual error is caused in the initialiser of your Config class. Check what your Config class does at line 17, and why it might be passing a null to the Properties loader.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.