You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "wangl123 (Jira)" <ji...@apache.org> on 2021/12/14 15:18: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=17459232#comment-17459232 ]
wangl123 commented on CXF-7932:
-------------------------------
Was this problem resolved? why does my project still throw this exception?
my project is built with jdk11, and it works well in my idea workspace, but goes wrong running with fat jar.
my cfx version is 3.4.5, and also add dependencies of org.glassfish.jaxb(version 2.3.0).
[~ffang] given a solution to solve it, but i can't understand the true reason. my fat jar contains the necessary dependencies of jaxb api.
my project built with gradle, not maven.
> 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 Yue Fang
> Priority: Major
> Labels: jdk11, spring-boot
> Fix For: 3.3.0
>
> Attachments: sandbox-springboot-cxf-ws-jdk11.tar, 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
(v8.20.1#820001)