How to load a "cxf.xml" file from an EJB module

168 views
Skip to first unread message

negora

unread,
Nov 29, 2021, 2:35:49 PM11/29/21
to WildFly

Hi:

I've created a web service client from an existing WSDL, with Apache CXF. I've used the `cxf-codegen-plugin` of Maven to generate such client. That's equivalent to use the `wsdl2java` application from the command line, if I'm not wrong.

I've tested the client, both in a standalone application and from an EJB module (inside an EAR module), and it has worked fine. To make that Apache CXF automatically detects the `cxf.xml` file in the standalone application, I've had to add a Maven dependency towards `org.springframework:spring-context`. However, I've not been able to reproduce this behavior in the EJB module.

This is how my `jboss-deployment-structure.xml` looks:

```
<jboss-deployment-structure>

    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

    <deployment>
        <dependencies>
            <!-- Among other modules... -->
            <module name="org.apache.cxf.impl" export="true"/>
            <module name="org.springframework.spring-context" export="true"/>
        </dependencies>
    </deployment>

</jboss-deployment-structure>
```

As you can see, among other modules, I load `org.apache.cxf.impl`, which is used internally by this version of Wildfly (I know that it may disappear in future versions).

I've also created a system-wide module called `org.springframework.spring-context`, which contains only the JARs downloaded by Maven for the `org.springframework:spring-context` module. This is an attempt to mimic what happens in the standalone application.

After some unsuccessful attempts, I've tried to copy the `cxf.xml` file in the EAR's root, in the EJB's root... But no luck. I've the feeling that the problem is not the location of this file, but that Spring Context does not takes action.

By the way, I don't use Spring in my EAR application. I've added that dependency just so that the `cxf.xml` file is interpreted by Apache CXF.

Can you help me, Please?

Thank you!

negora

unread,
Nov 30, 2021, 2:52:11 AM11/30/21
to WildFly
Hi again:

After lots and lots of attempts and frustration, by a chance, I was able to make it work. This is what I did, in case it's useful to someone.

First, I took a look to the `module.xml` file of the `org.apache.cxf.impl` module, with the intention of getting some ideas about the semantics of this type of file. I already knew some tags, but I had doubts about others. I found out that this module is already requesting for a module called `org.springframework.spring`. But it's optional. Indeed, such module does not exist in Wildfly. So I renamed my module to that name, so that Apache CXF detected it automatically.

Then, I edited the `jboss-deployment-structure.xml` file. I deleted the dependency towards `org.springframework.spring-context`, and I added the attribute `meta-inf="export"` to `org.apache.cxf.impl`.

Sincerely, I wasn't sure about what I was doing with that attribute, but it worked. I don't know why my application needs to see the `META-INF` directory of CXF. I thought it had to be the other way around: that CXF would need to see root of my classpath, to find the `cxf.xml` file.

Now my problem is that, every time I re-deploy my EAR, my EJB module seems to see an older version of my WS client and throws a `ClassCastException`. But I better create a separate thread for that.

Salutes.
Reply all
Reply to author
Forward
0 new messages