whummer / jaxb-facets

Support for extended XSD features in JAXB: facets (restrictions on simple types), annotations, asserts, ...
Other
26 stars 18 forks source link

Spring boot 1.3.1 + jaxb-facets #29

Open adrien-schiehle opened 8 years ago

adrien-schiehle commented 8 years ago

Old conf without problem:

I have a project using spring-boot 1.2.4 For managing web services inside it, I'm using apache.cxf. 2.7.11

pom.xml :

<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-rt-frontend-jaxws</artifactId>
  <version>${cxf.version}</version>
  <exclusions>
    <exclusion>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
    </exclusion>
    <exclusion>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-rt-transports-http</artifactId>
  <version>${cxf.version}</version>
</dependency>

<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.2.7-facets-1.0.5</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.2.6-facets-1.3.1</version>
</dependency>

New conf (with problem)

I tried to move to spring boot 1.2.4 -> 1.3.1. Which let to an incompatibility with my current apache.cxf dependency. 2.7.11 -> 3.1.4 (May have been a bad idea)

The problem is this one uses com.sun.xml.bind:jaxb-core:2.2.11 Which seems incompatible with com.sun.xml.bind:jaxb-imp:2.2.6-facets-1.3.1

During mvn install, the following error :

Caused by: java.lang.NoSuchFieldError: REFLECTION
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:93)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:455)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1174)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)

If I try to keep apache.cxf in version 2.7.xx

I get this error :

Caused by: java.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.isCglibProxyClass(Ljava/lang/Class;)Z
    at org.apache.cxf.common.util.SpringAopClassHelper.getRealClassInternal(SpringAopClassHelper.java:85)
    at org.apache.cxf.common.util.ClassHelper.getRealClass(ClassHelper.java:65)
    at org.apache.cxf.jaxws.EndpointImpl.getImplementorClass(EndpointImpl.java:215)

It would be really useful for me to migrate to spring boot 1.3.1 since they include Linux service integration. I would be a shame to have to remove Jaxb-facets for doing that.

whummer commented 8 years ago

Thanks for reporting. I pushed a new branch 2.2.11 which uses the latest version of JAXB. This should solve the version conflict.

Can you try the following dependency in your pom.xml file:

<dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.11-facets-1.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11-facets-1.4.0</version>
        </dependency>
        ...
    </dependencies>

(Don't forget to also add the <repository> entry as specified in the README.md.)

If that does not solve your issue, can you please create a test case that fails, and submit it as a pull request onto the current master branch. I can then look into the issue in more detail. Thanks

adrien-schiehle commented 8 years ago

Thank you for this quick reply. Unfortunatly the new version doesn't solve my problem.

Since my problem comes from integrating your solution inside a project with spring-boot 1.3.1, I don't see where you wish me to put my test case.

-> I created another public repo, I named jaxb-facets-issue29 here : https://github.com/adrien-schiehle/jaxb-facets-issue29

It contains a project example integrating your jaxb-facets and spring-boot 1.3.1. It fails on execution.