Question

After setting up a small JAX-RS application which I deployed on WildFly I am trying to add Spring support to RestEasy. I want to use the resteasy-spring module which is included in WildFly. When deploying the WAR I get a ClassNotFoundException:

 Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.spring.SpringContextLoaderListener from [Module "deployment.mk-backend-8.0.0-SNAPSHOT.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197) [jboss-modules.jar:1.3.0.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443) [jboss-modules.jar:1.3.0.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431) [jboss-modules.jar:1.3.0.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373) [jboss-modules.jar:1.3.0.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118) [jboss-modules.jar:1.3.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.addListener(UndertowDeploymentInfoService.java:1145)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.createServletConfig(UndertowDeploymentInfoService.java:734)
... 6 more

I included the module in my Manifest file which looks like this:

Manifest-Version: 1.0
Dependencies: org.jboss.resteasy.resteasy-spring export

In my web.xml I included the SpringContextLoaderListener

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
    </listener-class>
</listener>

I am completely new to WildFly. I went through a lot of documentation but I can't find anything that helps me.. What am I doing wrong?

Was it helpful?

Solution

I was dealing with a very similar issue... If you don't include a dependency in WEB-INF/lib you can force Wildfly to load this dependency from server classpath, or even exclude it if it's conflicting with specific lib versions that you used in your project. All you have to do is create the following XML file and save it in WEB-INF/jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
    <exclusions>
        <module name="org.jboss.resteasy.resteasy-jackson2-provider" />
    </exclusions>
    <dependencies>
        <module name="org.jboss.resteasy.resteasy-jackson-provider" services="import" />
        <module name="org.apache.httpcomponents" services="import"/>
        <module name="org.apache.commons.io" services="import"/>
    </dependencies>
</deployment>
</jboss-deployment-structure>

**You should notice that the markup inside the nodes <exclusion> and <dependencies> are just sample code, you should replace it with your own needed configuration.

Maybe the missing dependency on your project is marked as private on WildFly lib. Open the directory %JBOSS_HOME%/modules/system/layers/base/org/jboss/resteasy and check if the lib exists or if the module.xml of that lib contains the following markup

<properties>
    <property name="jboss.api" value="private"/>
</properties>

If a WildFly dependency is private, you should explicitly include it on the XML shown above (jboss-deployment-structure.xml). Otherwise, you just have to use it, there's no need to include the lib in your WEB-INF/lib nor manifest.mf file. However, if the dependency is not available on WildFly, I recommend you to include it in you WEB-INF/lib.

For more information, check ClassNotFoundException for ObjectMapper on WildFly 8.1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top