You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by ccomstock <ch...@influen.se> on 2012/06/19 12:53:58 UTC

New ExceptionMapper not loading

I am trying to create a new ExceptionMapper but when I throw the exception it
is placed in the log but the response is not handled correctly.  The request
content type is JSON but I just receive "This request requires HTTP
authentication ()." server error.  It appears it is not being loaded
correctly when the app loads.  Using version wink 1.2.0.


public class ResponseException extends WebApplicationException{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8128662372079247019L;
	
	private String exception;

	public ResponseException(String exception) {
		super();
		this.exception = exception;
	}

	public String getException() {
		System.out.println("Exception get method.");
		return exception;
	}
	
	

}

@Provider 
public class ResponseExceptionMapper implements
ExceptionMapper<ResponseException>{

	@Override 
    public Response toResponse( 
    		ResponseException ex) 
   { 
		System.out.println("ExceptionMapper toResponse.");
         return Response.status(Status.CONFLICT) 
                .entity(ex.getException()) 
                .build(); 
    } 
	
}

Throwing a new exception with this code:

throw new ResponseException("Test Exception");

I have tried loading the excpetion mapper by adding a appConfig file and
adding explicitly in my Application class and neither seems to work.

In web.xml:

<init-param>
			<param-name>applicationConfigLocation</param-name>
			<param-value>/WEB-INF/application</param-value>
		</init-param>

or in my Application class:

classes.add(ResponseException.class);
classes.add(ResponseExceptionMapper.class);

Is there something I am missing or that needs to be done to make this work.

--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/New-ExceptionMapper-not-loading-tp7572583.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.

Re: New ExceptionMapper not loading

Posted by ccomstock <ch...@influen.se>.
The problem I was running into was related to an uncaught exception in
another class which was causing the response to not be returned.  Everything
is working now.

--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/New-ExceptionMapper-not-loading-tp7572583p7572585.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.