InputStream.getResourceAsStream() giving null pointer exception

后端 未结 6 1445
广开言路
广开言路 2020-12-11 19:08

The line persistenceProperties.load(is); is throwing a nullpointerexception in the following method. How can I resolve this error?

6条回答
  •  余生分开走
    2020-12-11 19:46

    I recently had the same problem and came upon the solution that I had to put my resources in a path the same way organized as where was getClass().getResourceAsStream(name) situated. And I still had a problem after doing that. Later on, I discovered that creating a package org.smth.smth only had created a folder named like that "org.smth.smth" and not a folder org with a folder smth and a folder inside smth... So creating the same path structure solved my problem. Hope this explanation is understandable enough.

提交回复
热议问题