0
votes

I'm using Wildfly 11 with Java 8. Previously I was building a WAR file, which required the dom4j JAR file. Rather than including it in the WAR's WEB-INF/lib directory, I linked to the Wildfly modules JAR by adding an entry in the WEB-INF/jboss-deployment-structure.xml. Now I want to package this WAR as part of an EAR. So I created a jboss-deploymebnt-structure.xml file at teh root of the EAR, with these lines

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
        <deployment>
                <sub-deployment name="myapp.war">
                        <dependencies>
                        ...
                                <module name="org.dom4j" />

Now when I deploy the EAR, the WAR is failing to deploy with errors like

  service jboss.undertow.deployment.default-server.default-host./myapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./orgsclient: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/spring/infrastructure.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/STAXEventReader

What else do I need to do to tell the EAR file that the WAR is using the Wildly module dom4j as opposed to one I'm packaging with the EAR itself?

1

1 Answers

0
votes

Check if your jboss-deploymebnt-structure.xml is correctly placed in META-INF subfolder (beside with application.xml) of your built ear package. If you're using maven ear plugin you should put the xml file in:

ear/src/main/application/META-INF/jboss-deploymebnt-structure.xml

Please note the application folder is default resource folder for ear plugin.

If you still have a problem with NoClassDefFound, try to redeclare the dependency as 'ear global' and set it as exported

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.dom4j" slot="main" export="true"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

If you still have a problem then declare the module as a global module in wildlfy config (under the ee subsystem). Then you can get rid off the the jboss deployment descriptor at all.

    <subsystem xmlns="urn:jboss:domain:ee:4.0">
        <global-modules>
            <module name="org.dom4j">
        </global-modules>
        ...