You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2018/12/28 04:13:00 UTC

[jira] [Commented] (CXF-7932) JaxWsDynamicClientFactory in Spring Boot fat JAR with JDK11 leads to JAXBException ... doesnt contain ObjectFactory.class or jaxb.index

    [ https://issues.apache.org/jira/browse/CXF-7932?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16730024#comment-16730024 ] 

Freeman Fang commented on CXF-7932:
-----------------------------------

Hi,

Since JDK11, jaxb module(along with several others) was removed from JDK, and DynamicClientFactory needs to use jaxb api. So we need to put jaxb api on the classpath. The tricky part is that when using "java -jar", it will override the classpath you specified, so we can add the necessary classpath in manifest.

I will append a testcase based on yours to demonstrate it. After "mvn clean install" you  can use 
java -jar application.jar
with jdk11.

Freeman

> JaxWsDynamicClientFactory in Spring Boot fat JAR with JDK11 leads to JAXBException ... doesnt contain ObjectFactory.class or jaxb.index
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-7932
>                 URL: https://issues.apache.org/jira/browse/CXF-7932
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime, JAXB Databinding
>    Affects Versions: 3.2.7
>         Environment: OpenJDK 11
>            Reporter: Alexander Kosarev
>            Assignee: Freeman Fang
>            Priority: Major
>              Labels: jdk11, spring-boot
>         Attachments: sandbox-springboot-cxf-ws.zip
>
>
> I have a project based on Spring Boot and packaged as a fat JAR. When I try to run the application with Java 11, JaxWsDynamicClientFactory.createClient(...) leads to an error like 'javax.xml.bind.JAXBException: "..." doesnt contain ObjectFactory.class or jaxb.index'.
> {code:java}
> Caused by: java.lang.IllegalStateException: Unable to create JAXBContext for generated packages: "net.gcomputer.webservices" doesnt contain ObjectFactory.class or jaxb.index
>     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:417) ~[cxf-rt-frontend-simple-3.2.7.jar!/:3.2.7]
>     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:244) ~[cxf-rt-frontend-simple-3.2.7.jar!/:3.2.7]
>     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:237) ~[cxf-rt-frontend-simple-3.2.7.jar!/:3.2.7]
>     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:192) ~[cxf-rt-frontend-simple-3.2.7.jar!/:3.2.7]
>     at name.alexkosarev.sandbox.SandboxSpringbootCxfWsApplication.lambda$commandLineRunner$0(SandboxSpringbootCxfWsApplication.java:33) [classes!/:1.0.0]
>     at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
>     ... 13 common frames omitted
> Caused by: javax.xml.bind.JAXBException: "net.gcomputer.webservices" doesnt contain ObjectFactory.class or jaxb.index
>     at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:284) ~[jaxb-runtime-2.3.0.jar!/:2.3.0]
>     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
>     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
>     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
>     at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
>     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:217) ~[jaxb-api-2.3.1.jar!/:2.3.0]
>     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:175) ~[jaxb-api-2.3.1.jar!/:2.3.0]
>     at javax.xml.bind.ContextFinder.find(ContextFinder.java:353) ~[jaxb-api-2.3.1.jar!/:2.3.0]
>     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:508) ~[jaxb-api-2.3.1.jar!/:2.3.0]
>     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:413) ~[cxf-rt-frontend-simple-3.2.7.jar!/:3.2.7]
>     ... 18 common frames omitted
> {code}
> Startup command looks like:
> {code:java}
> java -jar application.jar
> {code}
> Problem doesn't appear if I use 'exploded' (unzipped) JAR instead of fat. Startup command looks like:
> {code:java}
> java -classpath "/path/to/BOOT-INF/classes:/path/to/BOOT-INF/lib/*" my.main.ClassName{code}
> Problem also doesn't appear if I run the application with Java 8 (with both jars).
> [~snicoll] suggested to post it here, because "it might be related to the way the resources is located".



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)