Jetty 9.0 embedded and RestEasy 3.0 keeps throwing NoSuchMethodError

前提是你 提交于 2019-11-30 09:18:29

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.

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!

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!