jaxrs - error throws in interceptor return status 500 <p>I'm bulid rest api using jax-rs. To handle authentication I'm using Interceptor. When auth failed I return WebApplicationException like:</p> <pre><code>try { Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(policy.getUserName(), policy.getPassword())); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(authentication); } catch (AuthenticationServiceException | BadCredentialsException e) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); //TODO set response status } </code></pre> <p>but it returns startus 500 instead 401.</p> <p>When i throw WebApplicationExceptions in services it return statuses that I set but in interceptor it didn't worked. How to return 401 from interceptor?</p> <p>jaxrs:server config:</p> <pre><code>&lt;jaxrs:server id="restService" address="/rest"&gt; &lt;jaxrs:serviceBeans&gt; &lt;ref bean="serviceBean"/&gt; &lt;/jaxrs:serviceBeans&gt; &lt;jaxrs:inInterceptors&gt; &lt;ref bean="securityInterceptor"/&gt; &lt;/jaxrs:inInterceptors&gt; &lt;/jaxrs:server&gt; &lt;bean id="serviceBean" class="some_package.CustomerService"/&gt; &lt;bean id="securityInterceptor" class="some_package.AuthenticatorInterceptor"/&gt; </code></pre>