1 Reply Latest reply on Nov 1, 2013 4:21 PM by Christian Sadilek

    Connecting to a 3'rd party RESTful web service

    Ara Tatous Newbie

      I'd like to use Errai to connect to one of our already existing web service.

       

      1- I duplicated the JAX-RS annotated interface class and placed it in client/shared package.

      2- In Maven pom.xml, I've added dependency to server DTO objects.

       

       

      But, I keep getting the following exception from Jetty start up.

       

      java.lang.NoClassDefFoundError: javax/ws/rs/ext/WriterInterceptor

      at java.lang.ClassLoader.defineClass1(Native Method)

      at java.lang.ClassLoader.defineClass(ClassLoader.java:792)

      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

      at java.security.AccessController.doPrivileged(Native Method)

      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

      at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload$WebAppClassLoaderExtension.findClass(JettyLauncher.java:367)

      at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366)

      at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)

      at org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:499)

      at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:305)

      at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225)

      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67)

      at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.init(FilterDispatcher.java:39)

      at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:593)

      at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)

      at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)

      at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)

      at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)

      at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:463)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)

      at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)

      at org.mortbay.jetty.Server.doStart(Server.java:222)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667)

      at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500)

      at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055)

      at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804)

      at com.google.gwt.dev.DevMode.main(DevMode.java:309)

      Caused by: java.lang.ClassNotFoundException: javax.ws.rs.ext.WriterInterceptor

      at java.lang.ClassLoader.findClass(ClassLoader.java:523)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

      at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:352)

      at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)

      at java.lang.ClassLoader.defineClass1(Native Method)

      at java.lang.ClassLoader.defineClass(ClassLoader.java:792)

      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

      at java.security.AccessController.doPrivileged(Native Method)

      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

      at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload$WebAppClassLoaderExtension.findClass(JettyLauncher.java:367)

      at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366)

      at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)

      at org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:499)

      at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:305)

      at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225)

      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67)

      at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.init(FilterDispatcher.java:39)

      at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:593)

      at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)

      at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)

      at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)

      at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)

      at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:463)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)

      at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)

      at org.mortbay.jetty.Server.doStart(Server.java:222)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667)

      at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500)

      at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055)

      at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804)

      at com.google.gwt.dev.DevMode.main(DevMode.java:309)

       

       

      With Errai JaxRs support, is it possible to hit 3'rd party web services, if yes what are the steps to achieve this?

       

      PS, I ran example JaxRs without a hitch.

        • 1. Re: Connecting to a 3'rd party RESTful web service
          Christian Sadilek Master

          Hi Ara,

           

          Yes, you can interact with 3rd party REST services using Errai JAX-RS. The problem you're seeing indicates that RestEasy can't bootstrap in your Jetty instance because the following class can't be found: javax/ws/rs/ext/WriterInterceptor

           

          This class is part of JAX-RS 2.0. So, you will need to upgrade your RestEasy version to e.g. 3.0.5.Final.


          Since you plan to interact with a 3rd party service, is it even your intention to deploy a REST endpoint in Jetty? You could simply use Errai JAX-RS to communicate with an existing service running somewhere else. In that case simply get rid of the configuration in web.xml and don't deploy the RestEasy jars.


          Cheers,

          Christian