Note that there are some explanatory texts on larger screens.

plurals
  1. POResteasy does not finds ExceptionMapper provider
    primarykey
    data
    text
    <p>I have tried a lot of things to make this work, but it is not working anyway. Also, I don't find proper documentation about this. I am trying to implement a <code>CustomExceptionMapper</code> for my <code>CustomException</code> type. The <code>CustomException</code> is thrown correctly, but it is not catched.</p> <p>I thought that annotating the <code>CustomExceptionMapper</code> with <code>@Provider</code> was enough, but it isnot detected. I have tried to allow scanning in web.xml, but I've found this: <a href="https://issues.jboss.org/browse/AS7-1739" rel="nofollow">https://issues.jboss.org/browse/AS7-1739</a> . I am using 7.0.1 Final. Probably the solution is changing of version, but this decision is not up to me.</p> <p>I have also found that you can try to override the <code>getClasses()</code> or <code>getSingletons</code> method and add there your <code>CustomExceptionMapper</code>, but it is just not detecting it.</p> <p>How my Application class looks like:</p> <pre><code>import java.util.HashSet; import java.util.Set; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @ApplicationPath("/service") public class MyApp extends Application { @Override public Set&lt;Class&lt;?&gt;&gt; getClasses() { Set&lt;Class&lt;?&gt;&gt; classes = new HashSet&lt;Class&lt;?&gt;&gt;(); classes.add(TestExceptionMapper.class); return classes; } } </code></pre> <p>And the Mapper</p> <pre><code>@Provider public class TestExceptionMapper implements ExceptionMapper&lt;TestException&gt; { public Response toResponse(TestException ex) { //something, but I cannot reach it. } } </code></pre> <p>Web.xml</p> <pre><code> &lt;context-param&gt; &lt;param-name&gt;resteasy.providers&lt;/param-name&gt; &lt;param-value&gt;com.mycompany.rest.exceptions.TestExceptionMapper&lt;/param-value&gt; &lt;/context-param&gt; &lt;servlet&gt; &lt;servlet-name&gt;RestletServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.restlet.ext.servlet.ServerServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;org.restlet.application&lt;/param-name&gt; &lt;param-value&gt;com.mycompany.rest.application.myApplication&lt;/param-value&gt; &lt;/init-param&gt; &lt;/servlet&gt; </code></pre> <p>And the service which is being called through URL:</p> <pre><code>@Stateless @Path("/somePath") public class someService { @GET //this should be post, but for testing I'm using get @Path("/some/update/someth") @Produces() public String updateSometh(@NotNull @QueryParam("key") String key, @QueryParam(value = "somethID") Long somethID) throws TestException { // .... } </code></pre> <p>If you call this with the correct parameters, it works. But if you put a bad parameter, it does not.<br> I would like to say too that the application is working, but I just wanted to add the Mappers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload