Questions Tagged With jax-rshttps://answers.axonivy.com/tags/jax-rs/?type=rss&user=Genzer%20Hawkerquestions tagged <span class="tag">jax-rs</span>enMon, 10 Sep 2018 02:24:40 -0400How can I use JAX-RS ContainerRequestFilter/ResponseFilter for my JAX-RS resources.https://answers.axonivy.com/questions/3412/how-can-i-use-jax-rs-containerrequestfilter-responsefilter-for-my-jax-rs-resources<p>Hi,</p> <p>I want to implement my own <code>ContainerRequestFilter</code> and <code>ContainerResponseFilter</code> for my JAX-RS resources in my Axon.ivy projects. Typically, I would create an implementation of the filter:</p> <pre><code>import java.util.logging.*; @Provider public class MyRequestFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { Logger.getLogger("Test").log(Level.WARNING, "LOOK MA! IT WORKS"); } } </code></pre> <p>I assume that Jersey will register my filter and it will works. However, I got </p> <pre><code>javax.servlet.ServletException: java.lang.IllegalStateException: Request scope has been already shut down. at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) ... Caused by: java.lang.IllegalStateException: Request scope has been already shut down. at jersey.repackaged.com.google.common.base.Preconditions.checkState(Preconditions.java:173) at org.glassfish.jersey.process.internal.RequestScope.retrieveCurrent(RequestScope.java:239) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:314) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) ... 46 more </code></pre> <p>..when I call my resources.</p> <p>Is it possible (at all) to use <code>ContainerRequestFilter/ResponseFilter</code> (and <code>Feature</code>, <code>DynamicFeature</code>) in an Axon.ivy project? And without introducing JAR files into <code>webapps/ivy/WEB-INF/lib/</code>?</p> <p>Thanks</p>Genzer HawkerMon, 10 Sep 2018 02:24:40 -0400https://answers.axonivy.com/questions/3412/how-can-i-use-jax-rs-containerrequestfilter-responsefilter-for-my-jax-rs-resourcesjax-rsjerseyrest