[
https://issues.apache.org/jira/browse/CXF-7925?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17034575#comment-17034575
]
Marian Macik commented on CXF-7925:
---
Hi guys, is this under some dicussion or should we close this?
> Dynamic WSDL Client creation fails on JDK 11 because it cannot compile
> generated classes
>
>
> Key: CXF-7925
> URL: https://issues.apache.org/jira/browse/CXF-7925
> Project: CXF
> Issue Type: Bug
> Components: Core, JAX-WS Runtime
>Affects Versions: 3.1.16, 3.2.7
> Environment: JDK 11
> Wildfly 14/EAP 7.2.0
> Apache CXF 3.1.16/3.2.7
>Reporter: Marian Macik
>Priority: Major
> Labels: Java11, jdk11
>
> Hi guys,
> sorry for a longer description, but I wrote here everything I know.
> I am working on kiegroup projects (drools,jbpm,optaplanner) and we are now
> upgrading to JDK 11. I am having the following issue (it works on JDK 8):
> Enivornment is JDK 11, Wildfly 14/EAP 7.2.0 and I am running there our tests.
> The test runs inside EAP and calls a
> [WebService|https://github.com/kiegroup/jbpm/blob/ccddd0812225ec7666111700e4138d3a32a28b66/jbpm-container-test/jbpm-remote-ejb-test/jbpm-remote-ejb-test-suite/src/main/java/org/jbpm/remote/ejb/test/mock/WebService.java#L32-L37]
> which is published from client side (outside container)
> [here|https://github.com/kiegroup/jbpm/blob/ccddd0812225ec7666111700e4138d3a32a28b66/jbpm-container-test/jbpm-remote-ejb-test/jbpm-remote-ejb-test-suite/src/main/java/org/jbpm/remote/ejb/test/mock/WebService.java#L47].
> So basically a code in the container is trying to connect to a WebService not
> deployed on that container.
> At first, the test creates a dynamic client
> [here|https://github.com/kiegroup/jbpm/blob/master/jbpm-workitems/jbpm-workitems-webservice/src/main/java/org/jbpm/process/workitem/webservice/WebServiceWorkItemHandler.java#L410]
> (classloader used is *Thread.currentThread().getContextClassLoader()*, its
> toString method says "ModuleClassLoader for Module
> "deployment.ejb-services-app.war" from Service Module Loader" - so it is
> basically a classloader for the deployed application), but it fails to do
> that with an exception:
> *Unable to create JAXBContext for generated packages: "org.jboss.sepro"
> doesnt contain ObjectFactory.class or jaxb.index*
> However, this is not the root cause. I debugged it and the root cause is
> following. When the client is being created, it downloads WSDL and then
> creates a classes for marshalling/unmarshalling using XJC. Classes are
> generated, I can find them in /tmp folder which is created by the code in
> [DynamicClientFactory.java|https://github.com/apache/cxf/blob/4f9923c32688c57e31f933c69d9c2a667f20d63d/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java#L366].
> After that, it's time for compilation which unfortunately fails in
> [DynamicClientFactory#compileJavaSrc|https://github.com/apache/cxf/blob/4f9923c32688c57e31f933c69d9c2a667f20d63d/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java#L389].
> When I dug deeper, I found that the classpath for compilation is set to ""
> (or rather not set) in
> [DynamicClientFactory#setupClasspath|https://github.com/apache/cxf/blob/4f9923c32688c57e31f933c69d9c2a667f20d63d/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java#L674]
> method. I guess this is fine, since it is only filled in case a
> URLClassLoader is used or in case we are in WebLogic, so there is a weblogic
> classloader. But since we are using just
> Thread.currentThread().getContextClassLoader(), which is not of type
> URLClassLoader, it does nothing. Then, before the compilation itself, CXF
> sets arguments for a compiler in
> [Compiler#addArgs|https://github.com/apache/cxf/blob/4f9923c32688c57e31f933c69d9c2a667f20d63d/core/src/main/java/org/apache/cxf/common/util/Compiler.java#L104]
> method. Here you can see it uses
> [java.class.path|https://github.com/apache/cxf/blob/4f9923c32688c57e31f933c69d9c2a667f20d63d/core/src/main/java/org/apache/cxf/common/util/Compiler.java#L105]
> system property to set the classpath. However, since we are on EAP, the
> java.class.path is set to:
> */home/mmacik/Workspace/jbpm/jbpm-container-test/jbpm-remote-ejb-test/jbpm-remote-ejb-test-suite/target/cargo/installs/jboss-eap-7.2.0.GA.CR2/jboss-eap-7.2/jboss-modules.jar*
> and that's it. The code doesn't pass there anything else, just this one JAR
> file.
> And now why it fails. I copied the classes generated by XJC and tried to
> compile them by myself (since programmatic way returns only true/false) using
> javac and they doesn't compile since JAXB annotations (JAXP-API