Jetty 9.0 embedded and RestEasy 3.0 keeps throwing NoSuchMethodError

后端 未结 4 1841
北恋
北恋 2020-12-31 19:40

Today I had the idea to build a very simple web application, which would be powered by a REST backend. Since I wanted a very lightweight server I started looking at Jetty. A

相关标签:
4条回答
  • 2020-12-31 20:04

    Had the very same problem when trying to deploy a jax-rs (with resteasy) to glassfish 3.1.2.2. Tried to resolve what caused the inconsistency, took for hours and couldn't find it in the end - glassfish behavior became more and more strange.

    My recommendation for everyone trying to run resteasy on gf: stop it and use jersey.

    0 讨论(0)
  • 2020-12-31 20:11

    I ran into this issue as well and it took me forever to figure out how to resolve it. Kevin Day was right. The issue was that one of the dependencies in my POM indirectly pulled in Jackson and that dependency was placed in the POM file before the jaxrs dependency. A fix was to simply move the jaxrs dependency to the top of the POM file so it gets picked up before Jackson.

    0 讨论(0)
  • 2020-12-31 20:12

    I just stumbled upon the same issue. The solution was to add the jaxrs-api explicitly as the first dependency in the list of dependencies.

    <dependencies>
      <!-- jaxrs-api is the very first dependency -->
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>jaxrs-api</artifactId>
        <version>3.0.4.Final</version>
      </dependency>
      <!-- here come the other depdendencies -->
    </dependencies> 
    

    Jackson uses the jsr311-api that provides the same Response class that is used by the BuiltResponse class. Unfortunately, this Response does not contain the getHeaders() method. So even though the dependency is resolved, it is using a wrong class. If somehow the Jackson dependency gets before the Resteasy one, then the exception above will be raised.

    0 讨论(0)
  • 2020-12-31 20:21

    I had the very same problem. First of all it was working using JAX-RS 2 and then it was migrated to JAX-RS 3, so I thought it had something to do with that. After failing in trying to get JBoss use JAX-RS 3 from app via Maven and jboss-deployment-structure.xml, I tried upgrading JBoss modules, which can be done using the following procedure:

    3.1. Upgrading Resteasy Within JBoss AS 7 Resteasy is bundled with JBoss AS 7. You will likely have the need to upgrade Resteasy in AS7. The Resteasy distribution comes with a zip file called resteasy-jboss-modules-3.0.1.Final.zip. Unzip this file while with the modules/ directory of the JBoss AS7 distribution. This will overwrite some of the existing files there.

    Source: http://docs.jboss.org/resteasy/docs/3.0.1.Final/userguide/pdf/resteasy-reference-guide-en-US.pdf

    Hope it helps!

    0 讨论(0)
提交回复
热议问题