Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

@PropertySource problem, getting an NPE ;(

 
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
straws are for suckers. tiny ads are for attractive people.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic