Reputation: 2382
Can anyone explain me why if I have my class so defined
public abstract class GenericClient
{
private static final Logger LOG = LoggerFactory.getLogger(GenericClient.class);
@Inject
@ConfigProperty( name = "dirx-ws.url" )
private String url;
private final Client client;
private HttpHeaders httpHeaders;
public GenericClient()
{
this.client = ClientBuilder.newClient();
}
public void setHttpHeaders( final HttpHeaders httpHeaders )
{
this.httpHeaders = httpHeaders;
}
protected HttpHeaders getHttpHeaders()
{
return this.httpHeaders;
}
protected Client getClient()
{
return this.client;
}
protected MultivaluedMap<String, Object> getHeaders()
{
final MultivaluedMap<String, String> myHttpHeaders = this.httpHeaders.getRequestHeaders();
final MultivaluedMap<String, Object> result = new MultivaluedHashMap<String, Object>();
myHttpHeaders.forEach(( name, values ) -> {
result.putSingle(name, values.size() != 1 ? values : values.get(0));
});
printHeaderInfo();
return result;
}
protected UriBuilder createURIBuilder( final String... paths )
{
final UriBuilder uriBuilder = UriBuilder.fromUri(this.url);
for (final String path : paths)
{
uriBuilder.path(path);
}
return uriBuilder;
}
}
there is no error, while if I define it this way (the only changes are private UriBuilder createdURI; and and the updated method createURIBuilder)
public abstract class GenericClient
{
private static final Logger LOG = LoggerFactory.getLogger(GenericClient.class);
@Inject
@ConfigProperty( name = "dirx-ws.url" )
private String url;
private final Client client;
private HttpHeaders httpHeaders;
private UriBuilder createdURI;
public GenericClient()
{
this.client = ClientBuilder.newClient();
}
public void setHttpHeaders( final HttpHeaders httpHeaders )
{
this.httpHeaders = httpHeaders;
}
protected HttpHeaders getHttpHeaders()
{
return this.httpHeaders;
}
protected Client getClient()
{
return this.client;
}
protected MultivaluedMap<String, Object> getHeaders()
{
final MultivaluedMap<String, String> myHttpHeaders = this.httpHeaders.getRequestHeaders();
final MultivaluedMap<String, Object> result = new MultivaluedHashMap<String, Object>();
myHttpHeaders.forEach(( name, values ) -> {
result.putSingle(name, values.size() != 1 ? values : values.get(0));
});
printHeaderInfo();
return result;
}
protected final UriBuilder createURIBuilder( final String... paths )
{
if (this.createdURI == null)
{
this.createdURI = UriBuilder.fromUri(this.url);
for (final String path : paths)
{
this.createdURI.path(path);
}
}
return this.createdURI;
}
}
I get the error
WELD-001410: The injection point has non-proxyable dependencies: [BackedAnnotatedField] @Inject private ch.ethz.id.sws.iamws.webservices.endpoint.RequestInterceptor.userClient [INFO] at ch.ethz.id.sws.iamws.webservices.endpoint.RequestInterceptor.userClient(RequestInterceptor.java:0)
My RequestScoped UserClient class has (only) an empty public constructor and it extends GenericClient.
Upvotes: 0
Views: 640
Reputation: 2382
Problem solved. Removing final from createURIBuilder method did the job.
I would be glad if someone could explain me anyway the reason why setting the method as 'final' is a problem.
Upvotes: 0