On Jan 25, 2011, at 9:00 PM, Martin Matula wrote:
> Hi James,
>
> On Jan 25, 2011, at 7:23 PM, James Jones wrote:
>
>> @Path("/service")
>> @PerSession
>> @Produces("some output type")
>> public class MyResource extends MyBaseResource {
>>
>> public MyResource(@Context UriInfo uriInfo, @Context
>> HttpServletRequest request, @Context Response response){
>> super(request);
>> }
>>
>> So, it can't figure out the javax.rs.ws.core.Response dependency?
>
> Right, injecting Response does not make sense in this context. What
> is your intent?
Also there should be something in the log stating that Response cannot
be injected into the constructor of that class. Before those log
entries you should see:
"The following errors and warnings have been detected with resource
and/or provider classes:"
I agree the exception stack trace is confusing. Not sure how to avoid
that since we fail on deployment by throwing that exception, so it is
printed out by the web container. FWIW see the code below for logging
the error messages.
Paul.
private static void processErrorMessages(boolean throwException,
List<ErrorMessage> messages) {
final StringBuilder sb = new StringBuilder();
boolean isFatal = false;
for (ErrorMessage em : messages) {
if (sb.length() > 0) {
sb.append("\n");
}
sb.append(" ");
if (em.isFatal) {
sb.append("SEVERE: ");
} else {
sb.append("WARNING: ");
}
isFatal |= em.isFatal;
sb.append(em.message);
}
final String message = sb.toString();
if (isFatal) {
LOGGER.severe("The following errors and warnings have
been detected with resource and/or provider classes:\n" + message);
if (throwException) {
throw new ErrorMessagesException(new
ArrayList<ErrorMessage>(messages));
}
} else {
LOGGER.warning("The following warnings have been detected
with resource and/or provider classes:\n" + message);
}
}