0

This error blows my brain. All the junit tests is fine but when my application loads as plugin for another application I have an errors. The beans.xml is 100% at root of jar file but for some reason the main application, that loads my plugin can't find the file. Why?

In my application's boot method I call new ClassPathXmlApplicationContext("beans.xml"); throws

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist

or

new FileSystemXmlApplicationContext(getClass().getClassLoader().getResource("beans.xml").getPath()); throws

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [file:/C:/path/to/my.jar!/beans.xml]; nested exception is java.io.FileNotFoundException: C:\path\to\my.jar!\beans.xml (The system cannot find the path specified)


UPD: The problem was the application uses custom classloader that does not load resource files in root, META-INF and etc. but only classes

2
  • What do you mean by 'root of jar file', can you check in what path it is located? Commented Sep 15, 2015 at 19:21
  • @Jama I mean that beans.xml located in jar file as it must be. Commented Sep 15, 2015 at 19:34

2 Answers 2

1

The FileNotFoundException that you get really points out that the beans.xml file is not in your jar at the place where you think it is. I would have a look inside that jar. You can for example open the jar with the 7-zip tool. I find that this provides useful insight when you get errors like the one you report.

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

Comments

1

If you're getting the FileNotFoundException it is because the file is not located where you're looking for it. The beans.xml file must be located in src/main/resources

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.