1 Reply Latest reply on Dec 18, 2013 1:45 PM by Cristian Miranda

    Error when invoking REST Service

    Cristian Miranda Newbie

      Hi guys,

       

           I have the following REST service:

       

      package app.client.shared.service;
      
      import java.util.List;
      
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.Produces;
      
      import com.magick.models.shared.Strategy;
      
      @Path("enabledstrategies")
      public interface EnabledStrategies {
      
        @GET
        @Produces("application/json")
        public List<Strategy> listAllEnabledStrategies();
      
      }
      
      

       

      package app.server.service;
      
      import java.util.List;
      
      import javax.inject.Inject;
      
      import app.client.shared.service.EnabledStrategies;
      import app.server.persistence.StrategyDAO;
      
      import com.magick.models.shared.Strategy;
      
      public class EnabledStrategiesImpl implements EnabledStrategies {
      
        @Inject
        private StrategyDAO strategyDAO;
      
        @Override
        public List<Strategy> listAllEnabledStrategies() {
             return this.strategyDAO.getEnabledStrategies();
        }
      
      }
      
      

       

      ... here is my web.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
      
      
        <servlet>
        <servlet-name>BootstrapServlet</servlet-name>
        <servlet-class>app.core.BootstrapServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        </servlet>
      
      
          <!--
          <security-constraint>
              <web-resource-collection>
                  <web-resource-name>SECURE</web-resource-name>
                  <url-pattern>/*</url-pattern>
              </web-resource-collection>
              <user-data-constraint>
                  <transport-guarantee>CONFIDENTIAL</transport-guarantee>
              </user-data-constraint>
          </security-constraint>
          -->
      
      
          <servlet>
              <servlet-name>ErraiServlet</servlet-name>
              <servlet-class>org.jboss.errai.bus.server.servlet.DefaultBlockingServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
      
      
          <servlet-mapping>
              <servlet-name>ErraiServlet</servlet-name>
              <url-pattern>*.erraiBus</url-pattern>
          </servlet-mapping>
      
      
          <servlet>
              <servlet-name>jUnitHostImpl</servlet-name>
              <servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
          </servlet>
      
      
          <servlet-mapping>
              <servlet-name>jUnitHostImpl</servlet-name>
              <url-pattern>/app/junithost/*</url-pattern>
          </servlet-mapping>
      
      
          <listener>
              <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
          </listener>
      
      
          <listener>
              <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
          </listener>
      
      
          <filter>
              <filter-name>ShiroFilter</filter-name>
              <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
          </filter>
      
      
          <filter-mapping>
              <filter-name>ShiroFilter</filter-name>
              <url-pattern>/*</url-pattern>
          <!--    <dispatcher>REQUEST</dispatcher>
              <dispatcher>FORWARD</dispatcher>
              <dispatcher>INCLUDE</dispatcher>
              <dispatcher>ERROR</dispatcher> -->
          </filter-mapping>
        
          <context-param>
              <param-name>errai.properties</param-name>
              <param-value>/WEB-INF/errai.properties</param-value>
          </context-param>
      
      
          <context-param>
              <param-name>login.config</param-name>
              <param-value>/WEB-INF/login.config</param-value>
          </context-param>
      
      
          <context-param>
              <param-name>users.properties</param-name>
              <param-value>/WEB-INF/users.properties</param-value>
          </context-param>
      
      
          <servlet>
              <servlet-name>javax.ws.rs.core.Application</servlet-name>
              <load-on-startup>1</load-on-startup>
          </servlet>
      
      
          <servlet-mapping>
              <servlet-name>javax.ws.rs.core.Application</servlet-name>
              <url-pattern>/rest/*</url-pattern>
          </servlet-mapping>
      
      
      </web-app>
      

       

      I'm using JBoss AS 7.1.1.

      When I try to access to the REST Service with the following URL: http://127.0.0.1:8888/rest/enabledstrategies the following exception occurs:

       

      15:22:16,615 SEVERE [org.jboss.resteasy.core.SynchronousDispatcher] (http--127.0.0.1-8888-1) Failed executing GET /enabledstrategies: org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.ext.ContextResolver

        at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53) [resteasy-jaxrs-2.3.2.Final.jar:]

        at com.sun.proxy.$Proxy129.getContext(Unknown Source)

        at org.apache.cxf.jaxrs.provider.AbstractAegisProvider.getAegisContext(AbstractAegisProvider.java:73) [cxf-bundle-jaxrs-2.2.10.jar:2.2.10]

        at org.apache.cxf.jaxrs.provider.AegisElementProvider.writeTo(AegisElementProvider.java:74) [cxf-bundle-jaxrs-2.2.10.jar:2.2.10]

        at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:100) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:585) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:506) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.2.Final.jar:]

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

        at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) [shiro-web-1.2.2.jar:1.2.2]

        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) [shiro-web-1.2.2.jar:1.2.2]

        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [shiro-core-1.2.2.jar:1.2.2]

        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [shiro-core-1.2.2.jar:1.2.2]

        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) [shiro-core-1.2.2.jar:1.2.2]

        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) [shiro-web-1.2.2.jar:1.2.2]

        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [shiro-web-1.2.2.jar:1.2.2]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

        at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466) [jbossweb-7.0.13.Final.jar:]

        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

        at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

       

      Any ideas? jfuerth mbarkley csa

      Thanks!