• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

@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!
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic