hello everyone what Im trying to do is prefill a CustomDetail Object with some properties with the help of @Value and @PostConstruct, then use this prefilled Object on a service but when the Object arrives to the service class its null already...
UPDATED!!!! this is the right code
@Service
public Class CustomDetail(){
ProxyObject prx;
...
@Value("#{myProperties.proxy.address}")
String propertyPrx;
@PostConstruct
private void setProperty(){
prx= new ProxyObject(propertyPrx);
}
.....
....
}
Now setProperty() method effectively does its job correctly, if I Start Tomcat on debug I can see that propertyPrx its good and the Object prx is NOT null... so new ProxyObject(propertyPrx) gets Called without any issues, at this point everything fine. now when I move to the service part and try to useit
public Class ServiceClient(){
....
...
@Autowired
CustomDetail cDetail;
....
...more code
cDetail.someMethod(a,n,y); //<---cDetail Object is null so I get a NullPointerException
}
any ideas why this is happening and why the @PostConstruct only gets initialized when Tomcat starts for the first time and when I try to injected into the service class is already null like if it never got initialized thanks for your help... I'm using SpringMVC 3.1 Tomcat