• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@PropertySource problem, getting an NPE ;(

 
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having some trouble using @PropertySource, I get an NPE when using 'env.getProperty(..).
Does anybody have any insight?

My environment:
JDK/JRE: 1.6.0_06
OS: Linux Mint 13
Spring: 4.1.6.RELEASE

The stacktrace

My properties file:

My config class:

Model class:

Failed attempts (a bit random!!):
#1 I have tried playing around with the @PropertySource annotation, for example using the file: prefix and absolute path to the properties file.
Dropping the backslash before the classpath eg/@PropertySource("classpath:com/mycompany/app/app.properties").
Putting the properties file in different places.

#2 I've also tried using @PropertySources containing an @PropertySource annotation too.

#3 I've added:
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

Any help/advice much appreciated!!
 
Billy Sclater
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I have an answer!

http://stackoverflow.com/questions/30285382/spring-propertysource-getting-an-npe

Thanks to Costi Ciudatu over at StackOverflow!
 
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic