[
https://issues.apache.org/jira/browse/KARAF-6727?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jean-Baptiste Onofré reassigned KARAF-6727:
-------------------------------------------
Assignee: Jean-Baptiste Onofré
> @Reference always null in business delegate
> -------------------------------------------
>
> Key: KARAF-6727
> URL: https://issues.apache.org/jira/browse/KARAF-6727
> Project: Karaf
> Issue Type: Question
> Components: karaf
> Affects Versions: 4.2.8
> Reporter: Nicolas Duminil
> Assignee: Jean-Baptiste Onofré
> Priority: Minor
>
> Hello,
> In a REST service deployed on Karaf 4.28, I'm trying to use a business
> delegate. The REST service starts well and I'm able to display the WADL, etc.
> But the business delegate reference is always null. Here is a code excerpt:
> {color:#9e880d}@Path{color}({color:#067d17}"/customers"{color})
> {color:#9e880d} @Produces{color}({color:#067d17}"application/xml"{color})
> {color:#9e880d} @Consumes{color}({color:#067d17}"application/xml"{color})
> {color:#0033b3} public class {color}{color:#000000}CustomerAPI
> {color} {
> {color:#9e880d}@Reference
> {color} {color:#0033b3}private {color}{color:#000000}CustomerDataService
> {color}{color:#871094}customerDataService{color};
> {color:#9e880d}@GET
> {color} {color:#0033b3}public {color}{color:#000000}Response
> {color}{color:#00627a}getCustomers{color}()
> {
> {color:#0033b3}return
> {color}{color:#000000}Response{color}.ok().entity({color:#000000}Objects{color}.requireNonNull({color:#871094}customerDataService{color},
> {color:#067d17}"CustomerDataService is
> null"{color}).getCustomers().stream().map({color:#000000}CustomerDto{color}::
> {color:#0033b3}new{color}).collect({color:#000000}Collectors{color}.toList())).build();
> }
> ...
> }
> Here above, an NPE is raised as the customersDataService property is null.
> The logfile displays the following:
> java.lang.NullPointerException: CustomerDataService is null
> at java.util.Objects.requireNonNull(Objects.java:246) ~[?:?]
> at
> fr.simplex_software.red_hat.fuse.osgi.standalone.customers.rest.CustomerAPI.getCustomers(CustomerAPI.java:26)
> ~[?:?]
> ...
> What did I miss here ? Many thanks in advance.
> Kind regards,
> Nicolas
--
This message was sent by Atlassian Jira
(v8.3.4#803005)