如何阻止Wildfly11自动加载Jar依赖中的@WebServiceProvider类
Since you can't modify the third-party JAR and don't want to disable the entire webservices subsystem or exclude the whole JAR, here are targeted fixes to stop Wildfly from scanning that specific GenServiceRouter class:
Option 1: Use jboss-webservices.xml (Application-Level Configuration)
Wildfly's webservices subsystem respects exclusion rules defined in a WEB-INF/jboss-webservices.xml file. Create this file with the following content to exclude the problematic class:
<jboss-webservices xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-webservices_1_0.xsd"> <webservices> <endpoint-config> <exclude-classes> <class>com.ca.gen80.wsrt.router.GenServiceRouter</class> </exclude-classes> </endpoint-config> </webservices> </jboss-webservices>
This tells Wildfly's webservices scanner to skip this exact class, so it won't attempt to load its missing WSDL while leaving the rest of the subsystem and third-party JAR functional.
Option 2: Fine-Tune jboss-deployment-structure.xml
If Option 1 doesn't work, modify your existing jboss-deployment-structure.xml to exclude the class from the webservices subsystem's scan scope:
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <!-- Remove the full webservices subsystem exclusion --> <subsystem xmlns="urn:jboss:domain:webservices:2.0"> <endpoint-scan-exclude> <class>com.ca.gen80.wsrt.router.GenServiceRouter</class> </endpoint-scan-exclude> </subsystem> </deployment> </jboss-deployment-structure>
This approach narrows down the exclusion to only the class causing issues, keeping the webservices subsystem active for other use cases.
Why Your Previous Attempts Didn't Work
- Disabling the entire webservices subsystem: Overkill, and caused unintended errors as you noticed.
beans.xmlwithbean-discovery-mode="none": CDI's bean scan doesn't cover@WebServiceProviderannotations—those are handled by Wildfly's dedicated webservices scanner, not CDI.jboss-scanning.xml: This controls general classpath scanning, but webservices has its own independent scanning mechanism that ignores these rules.
Both options above directly target the webservices subsystem's scanning logic, which is responsible for picking up @WebServiceProvider annotations.
内容的提问来源于stack exchange,提问作者trojanc

