22

i am getting the error when i try to upload a file based exactly off the example shown here Sample

The error is

Allocate exception for servlet com.testapp.rest.JaxRsActivator: java.lang.RuntimeException: Unable to find a public constructor for class org.jboss.resteasy.core.AsynchronousDispatcher

What can this mean?

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
user1438082
  • 2,740
  • 10
  • 48
  • 82

4 Answers4

74

If deploying to JBoss 7.x you need to change the scope of your resteasy dependencies to provided. This is because those particular libraries are already included in JBoss as modules:

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>2.2.1.GA</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-multipart-provider</artifactId>
    <version>2.2.0.GA</version>
    <scope>provided</scope>
</dependency>
Perception
  • 79,279
  • 19
  • 185
  • 195
  • 2
    To those coming here, also ensure that you check which versions of the libraries are already/actually deployed JBOSS - e.g your POM might be pointing to 2.2.0.GA, yet the server has 3.0.10.Final (as in my case), and this caused me so much headache! – JWL Feb 11 '15 at 08:49
  • 1
    What if I want a custom dependency of resteasy to be able to use it with different containers? am I stuck with the provided version? Seriously? – Fagner Brack Mar 16 '15 at 17:38
  • not worked! Changed stope, than update maven, clean, install, built but no luck – Chetan S. Choudhary Oct 13 '16 at 09:33
  • @Perception Can you elaborate what do you mean by `change the scope of your resteasy dependencies to provided`? I am using WildFly 10 on my eclipse and have dependency with this version `2.2.1.GA` defined in my `pom.xml` – Dan Mar 09 '18 at 16:02
4

I was using wildfly 10 to deploy my application when I got this error and tried the above solutions and didn't work for me and finally I had to exclude the jar resteasy-jaxrs using maven exclusions

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-servlet-initializer</artifactId>
        <version>3.0.19.Final</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <artifactId>resteasy-jaxrs</artifactId>
                <groupId>org.jboss.resteasy</groupId>
            </exclusion>
        </exclusions>
    </dependency>
Pipo
  • 4,653
  • 38
  • 47
CoderCoder
  • 358
  • 2
  • 7
  • On wildfly 10 it works for me https://stuetzpunkt.wordpress.com/2017/02/23/upload-an-image-to-wildfly-resteasy/ – elciospy Mar 04 '19 at 13:35
2

Like a charm

One more thing, make sure you check for resteasy

$ mvn dependency:tree | grep "resteasy"

[INFO] \- org.jboss.resteasy:resteasy-jaxrs:jar:3.0.10.Final:provided
[INFO]    +- org.jboss.resteasy:jaxrs-api:jar:3.0.10.Final:provided
lantrix
  • 441
  • 9
  • 17
Mike Nguyen
  • 1,024
  • 1
  • 11
  • 16
2

Maybe it's worth to mention that the RESTeasy documentation has information on how to upgrade the RESTeasy included in JBoss, which as mentioned above can cause some headache if you try to use another version.