Matt Vegas
Matt Vegas

Reputation: 493

Use ManagedProperty inside a RestController

I need you help to fix an issue I have.

Currently in a Bean I'm referring to the service in that way:

@ManagedBean(name="sslbean")
public class SslBean implements Serializable {
...
...
@ManagedProperty("#{sslService}")
SslService service;
public void setService(SslService service) {
    this.service = service;
}
...
...

and the access to the SslService is working without any issue.

So I thought that I can do the same inside a RestController:

@RestController
@RequestMapping("/payment")
public class PaymentController {
...
...
@ManagedProperty("#{sslService}")
SslService service;

@PostConstruct
public void init() {
    this.ssl_list = service.listSsl();
}

public void setService(SslService service) {
    this.service = service;
}
...
...
...

but on runtime I get that the service is null ( no error during tomcat startup)

Can someone help me to understand that and how to fix?

thanks for your help.

Upvotes: 0

Views: 16

Answers (0)

Related Questions