Skip to main content
added 553 characters in body
Source Link
WeMakeSoftware
  • 9.2k
  • 5
  • 36
  • 52

To narrow down the problem make sure that the ApplicationContext you're creating is successfully created.

This should return all of the beans' names from the given application context.

 context.getBeanDefinitionNames();

Update

If the ApplicationContext does not list any beans from your xml config, that might be an indication that the resource file is not accessible by the ClassPathXmlApplicationContext.

One way to check is to do something like this:

ClassPathXmlApplicationContext.class.getClassLoader().getResourceAsStream("application-config.xml")

This should return a valid not null stream in case the resource is accessible.

Note the format of the resource name. It should not include any prefixes like classpath: or classpath*:

To narrow down the problem make sure that the ApplicationContext you're creating is successfully created.

This should return all of the beans' names from the given application context.

 context.getBeanDefinitionNames();

To narrow down the problem make sure that the ApplicationContext you're creating is successfully created.

This should return all of the beans' names from the given application context.

 context.getBeanDefinitionNames();

Update

If the ApplicationContext does not list any beans from your xml config, that might be an indication that the resource file is not accessible by the ClassPathXmlApplicationContext.

One way to check is to do something like this:

ClassPathXmlApplicationContext.class.getClassLoader().getResourceAsStream("application-config.xml")

This should return a valid not null stream in case the resource is accessible.

Note the format of the resource name. It should not include any prefixes like classpath: or classpath*:

Source Link
WeMakeSoftware
  • 9.2k
  • 5
  • 36
  • 52

To narrow down the problem make sure that the ApplicationContext you're creating is successfully created.

This should return all of the beans' names from the given application context.

 context.getBeanDefinitionNames();