Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7932

JaxWsDynamicClientFactory in Spring Boot fat JAR with JDK11 leads to JAXBException ... doesnt contain ObjectFactory.class or jaxb.index

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      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'.

      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
      

      Startup command looks like:

      java -jar application.jar
      

      Problem doesn't appear if I use 'exploded' (unzipped) JAR instead of fat. Startup command looks like:

      java -classpath "/path/to/BOOT-INF/classes:/path/to/BOOT-INF/lib/*" my.main.ClassName

      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".

      Attachments

        1. sandbox-springboot-cxf-ws-jdk11.tar
          13.38 MB
          Freeman Yue Fang
        2. sandbox-springboot-cxf-ws.zip
          92 kB
          Alexander Kosarev

        Activity

          People

            ffang Freeman Yue Fang
            akosarev Alexander Kosarev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: