Skip to content
Advertisement

Spring/NetBeans – java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist

Whenever I try to run my java project, I get file not found exception saying that beans.xml cannot be found. I am using NetBeans and have read that I might need to set my classpath to the correct directory or the project will not run correctly (Eclipse does this automatically(?)). Running this same program with same library works with Eclipse. I don’t know if my problem is Spring related or classpath related (but I assume it’s a classpath issue).

MainApp.java

JavaScript

HelloWorld.java

JavaScript

beans.xml

JavaScript

ST

JavaScript

File and Project structures

Thanks for the help.

SOLUTION: In NetBeans the beans.xml type file you are using to instantiate your beans must contain it’s path. In my case, I had to type out:

JavaScript

Instead of just:

JavaScript

Advertisement

Answer

Your beans.xml is in hello package so you should refer it using:

JavaScript

P.S.: A better practice would be to place this in resources directory.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement