You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Aled Sage <al...@gmail.com> on 2019/12/04 21:39:20 UTC

IllegalAnnotationsException with CXF 3.3.2 in Karaf 4.2.7

Hi all,

I'm a committer on the Apache Brooklyn [1] and the winrm4j [2] projects.

We're upgrading Apache Brooklyn to Karaf 4.2.7 for the next release, and 
have hit a big problem trying to upgrade CXF to 3.3.2 (from 3.2.8).

We'd appreciate some help and advice for how to fix or work around this.

There is a lot more details (including of the error investigation) in 
this Apache Brooklyn email thread: [3].

We're now getting an IllegalAnnotationsException, with the underlying error:

Two classes have the same XML type name 
"{http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}objectFactory". Use 
@XmlType.name and @XmlType.namespace to assign different names to them.

It works when run outside of Karaf.

Comparing the OSGi bundles and package exports/imports, I'm guessing the 
underlying problem is that javax.xml.bind.annotation.XMLRegistry is now 
coming from two places:

package:exports | grep javax.xml.bind.annotation
javax.xml.bind.annotation.adapters    │ 2.2.8    │ 0   │ 
org.apache.felix.framework
javax.xml.bind.annotation.adapters    │ 2.3.2    │ 108 │ 
jakarta.xml.bind-api
javax.xml.bind.annotation             │ 2.2.8    │ 0   │ 
org.apache.felix.framework
javax.xml.bind.annotation             │ 2.3.2    │ 108 │ 
jakarta.xml.bind-api

The jakarta.xml.bind-api bundle wasn't in our Karaf distro before - only 
since we upgrade CXF (it comes from the feature cxf-specs, version 3.3.2).

The winrm4j-client OSGi bundle is also being upgraded to use CXF 3.3.2 - 
its package import is from jakarta.xml.bind-api.

---

The stack trace is:

2019-12-03T11:44:16,468 wmhGA3U2-[ut059oi7tk,ltajipcuun] WARN  103 
i.c.w.c.WinRmClient [ager-Ak6FHXbO-32] Error creating WinRm service with 
mbean strategy (trying other strategies): 
org.apache.cxf.service.factory.ServiceConstructionException
org.apache.cxf.service.factory.ServiceConstructionException: null
         at 
org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:355) 
~[!/:3.3.2]
         at 
org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) 
~[!/:3.3.2]
         at 
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:426) 
~[!/:3.3.2]
         at 
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528) 
~[!/:3.3.2]
         at 
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263) 
~[!/:3.3.2]
         at 
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199) 
~[?:?]
         at 
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103) 
~[!/:3.3.2]
         at 
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91) 
~[!/:3.3.2]
         at 
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159) 
~[!/:3.3.2]
         at 
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) 
~[?:?]
         at 
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:95) 
~[!/:3.3.2]
         at 
io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithBean(WinRmFactory.java:97) 
~[!/:?]
         <snip>
Caused by: 
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 
counts of IllegalAnnotationExceptions
         at 
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91) 
~[?:1.8.0_201]
         at 
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445) 
~[?:1.8.0_201]
         at 
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277) 
~[?:1.8.0_201]
         at 
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124) 
~[?:1.8.0_201]
         at 
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123) 
~[?:1.8.0_201]
         at 
com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147) 
~[?:1.8.0_201]
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[?:1.8.0_201]
         at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:1.8.0_201]
         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
~[?:1.8.0_201]
         at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201]
         at 
javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222) 
~[?:1.8.0_201]
         at javax.xml.bind.ContextFinder.find(ContextFinder.java:396) 
~[?:1.8.0_201]
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641) 
~[?:1.8.0_201]
         at 
org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:357) 
~[!/:3.3.2]
         at 
org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246) 
~[!/:3.3.2]
         at 
org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:498) 
~[!/:3.3.2]
         at 
org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:353) 
~[!/:3.3.2]
         ... 43 more

Aled

[1] 
https://lists.apache.org/thread.html/ead4351d187f7d7e7c257cb47f2490b3139d0de8d6fe15c43beea4d3%40%3Cdev.brooklyn.apache.org%3E

[2] https://github.com/cloudsoft/winrm4j/

[3] FIXME mailing list link


Re: IllegalAnnotationsException with CXF 3.3.2 in Karaf 4.2.7

Posted by Aled Sage <al...@gmail.com>.
Thanks Alexey,

Your pointers and the explanation were really useful for me.

As you suggested, it is now working for me with the following added to 
the winrm4j build (I also needed to include the "version=!"):

       <plugin>
         <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
         <configuration>
           <instructions>
               <Import-Package>
                 javax.xml.bind*;version=!,
                 *
               </Import-Package>
           </instructions>
         </configuration>
       </plugin>

This has got me back on the right path for upgrading CXF. Much appreciated.

Aled


On 05/12/2019 12:45, Alexey Markevich wrote:
> There was almost no changes in cxf-specs feature since 3.3.2 so I
> performed the check using the latest available version.
> Highlight: 'jakarta.xml.bind-api' is a dependency [1] and doesn't
> installed in case CXF features only:
>> feature:install cxf-jaxws cxf-http-async cxf-ws-addr
>> package:exports | grep javax.xml.bind.annotation
> javax.xml.bind.annotation.adapters                               |
> 2.2.8       | 0   | org.apache.felix.framework
> javax.xml.bind.annotation                                        |
> 2.2.8       | 0   | org.apache.felix.framework
>
> The dependency is satisfied by existing version range from your bundle.
> Version range comes from maven-bundle-plugin when no explicit
> configuration found.
> Configure plugin for import without version range like
>              <plugin>
>                  <groupId>org.apache.felix</groupId>
>                  <artifactId>maven-bundle-plugin</artifactId>
>                  <configuration>
>                      <instructions>
>                          <Import-Package>javax.xml.bind*,*</Import-Package>
>                      </instructions>
>                  </configuration>
>              </plugin>
>
> 1. http://karaf.922171.n3.nabble.com/features-xml-dependency-quot-true-quot-td3286359.html
>
> On 12/5/19, Aled Sage <al...@gmail.com> wrote:
>> Hi,
>>
>> Thanks for this.
>>
>> Not sure I follow though. Are you proposing we install cxf 3.3.4 instead
>> of 3.3.2, into our Karaf 4.2.7 distro?
>>
>> How does that fix the problem?
>>
>> cxf-jaxws 3.3.4 depends on feature cxf-http 3.3.4, which depends on
>> feature cxf-core 3.3.4, which depends on feature cxf-specs 3.3.4.
>>
>> cxf-specs 3.3.4 depends on bundle jakarta.xml.bind-api (same as for
>> 3.3.2). That bundle is being installed automatically by inclusion of the
>> feature. Unless we explicitly uninstall that bundle, we end up with
>> javax.xml.bind.annotation coming from the two places. Because
>> jakarta.xml.bind-api has the newer version, my bundle's import will use
>> that one (if we don't specify a version range).
>>
>> The relevant feature.xml file in Brooklyn [1] includes:
>>
>>       <feature name="brooklyn-software-winrm"
>> version="${project.version}" description="Brooklyn WinRM Software
>> Entities">
>> <bundle>mvn:org.apache.brooklyn/brooklyn-software-winrm/${project.version}</bundle>
>>           <feature>brooklyn-core</feature>
>>           <bundle
>> dependency="true">mvn:io.cloudsoft.windows/winrm4j/${winrm4j.version}</bundle>
>>           <bundle
>> dependency="true">mvn:io.cloudsoft.windows/winrm4j-client/${winrm4j.version}</bundle>
>> <bundle>mvn:org.apache.brooklyn/brooklyn-karaf-httpcomponents-extension/${project.version}</bundle>
>>           <feature>cxf-jaxws</feature>
>>           <feature>cxf-http-async</feature>
>>           <feature>cxf-ws-addr</feature>
>>       </feature>
>>
>> Other relevant CXF references in our feature.xml files are:
>>
>> brooklyn-server/karaf/features/src/main/feature/feature.xml:
>> <feature>cxf-jaxws</feature>
>> brooklyn-server/karaf/features/src/main/feature/feature.xml:
>> <feature>cxf-http-async</feature>
>> brooklyn-server/karaf/features/src/main/feature/feature.xml:
>> <feature>cxf-ws-addr</feature>
>> brooklyn-server/karaf/features/src/main/feature/feature.xml: <bundle
>> dependency="true">mvn:org.apache.cxf/cxf-rt-rs-security-cors/${cxf.version}</bundle>
>> brooklyn-server/karaf/features/src/main/feature/feature.xml: <bundle
>> dependency="true">mvn:org.apache.cxf/cxf-rt-frontend-jaxrs/${cxf.version}</bundle>
>> brooklyn-server/karaf/features/src/main/feature/feature.xml: <bundle
>> dependency="true">mvn:org.apache.cxf.karaf/cxf-karaf-commands/${cxf.version}</bundle>
>>
>> Aled
>>
>> [1]
>> https://github.com/apache/brooklyn-server/blob/master/karaf/features/src/main/feature/feature.xml#L229-L238
>>
>> (note that master has not been upgraded to CXF 3.3.2 yet; that's still
>> being tested in my branch).
>>
>>
>> On 05/12/2019 08:31, Alexey Markevich wrote:
>>> Hi Aled,
>>>
>>> jakarta.xml.bind-api bundle installed as dependency from cxf-specs
>>> feature.
>>> In case step-by step setup its not activated:
>>>
>>>> feature:repo-add cxf 3.3.4
>>>> feature:install http cxf-jaxws
>>>> package:exports | grep javax.xml.bind.annotation
>>> javax.xml.bind.annotation.adapters                               |
>>> 2.2.8       | 0   | org.apache.felix.framework
>>> javax.xml.bind.annotation                                        |
>>> 2.2.8       | 0   | org.apache.felix.framework
>>>
>>> To avoid package version range
>>> javax.xml.bind.annotation;version="[2.3,3)"
>>>
>>> build your bunlde specifying 'javax.xml.bind.annotation' as
>>> Import-Package (without version range).
>>> In this case package from 'org.apache.felix.framework' bundle should be
>>> used.
>>>
>>> On 12/5/19, Aled Sage <al...@gmail.com> wrote:
>>>> Hi all,
>>>>
>>>> I'm a committer on the Apache Brooklyn [1] and the winrm4j [2] projects.
>>>>
>>>> We're upgrading Apache Brooklyn to Karaf 4.2.7 for the next release, and
>>>> have hit a big problem trying to upgrade CXF to 3.3.2 (from 3.2.8).
>>>>
>>>> We'd appreciate some help and advice for how to fix or work around this.
>>>>
>>>> There is a lot more details (including of the error investigation) in
>>>> this Apache Brooklyn email thread: [3].
>>>>
>>>> We're now getting an IllegalAnnotationsException, with the underlying
>>>> error:
>>>>
>>>> Two classes have the same XML type name
>>>> "{http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}objectFactory". Use
>>>> @XmlType.name and @XmlType.namespace to assign different names to them.
>>>>
>>>> It works when run outside of Karaf.
>>>>
>>>> Comparing the OSGi bundles and package exports/imports, I'm guessing the
>>>> underlying problem is that javax.xml.bind.annotation.XMLRegistry is now
>>>> coming from two places:
>>>>
>>>> package:exports | grep javax.xml.bind.annotation
>>>> javax.xml.bind.annotation.adapters    │ 2.2.8    │ 0   │
>>>> org.apache.felix.framework
>>>> javax.xml.bind.annotation.adapters    │ 2.3.2    │ 108 │
>>>> jakarta.xml.bind-api
>>>> javax.xml.bind.annotation             │ 2.2.8    │ 0   │
>>>> org.apache.felix.framework
>>>> javax.xml.bind.annotation             │ 2.3.2    │ 108 │
>>>> jakarta.xml.bind-api
>>>>
>>>> The jakarta.xml.bind-api bundle wasn't in our Karaf distro before - only
>>>> since we upgrade CXF (it comes from the feature cxf-specs, version
>>>> 3.3.2).
>>>>
>>>> The winrm4j-client OSGi bundle is also being upgraded to use CXF 3.3.2 -
>>>> its package import is from jakarta.xml.bind-api.
>>>>
>>>> ---
>>>>
>>>> The stack trace is:
>>>>
>>>> 2019-12-03T11:44:16,468 wmhGA3U2-[ut059oi7tk,ltajipcuun] WARN  103
>>>> i.c.w.c.WinRmClient [ager-Ak6FHXbO-32] Error creating WinRm service with
>>>> mbean strategy (trying other strategies):
>>>> org.apache.cxf.service.factory.ServiceConstructionException
>>>> org.apache.cxf.service.factory.ServiceConstructionException: null
>>>>            at
>>>> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:355)
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:426)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
>>>>
>>>> ~[?:?]
>>>>            at
>>>> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
>>>>
>>>> ~[?:?]
>>>>            at
>>>> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:95)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithBean(WinRmFactory.java:97)
>>>>
>>>> ~[!/:?]
>>>>            <snip>
>>>> Caused by:
>>>> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2
>>>> counts of IllegalAnnotationExceptions
>>>>            at
>>>> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>
>>>> ~[?:1.8.0_201]
>>>>            at java.lang.reflect.Method.invoke(Method.java:498)
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)
>>>> ~[?:1.8.0_201]
>>>>            at javax.xml.bind.ContextFinder.find(ContextFinder.java:396)
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
>>>> ~[?:1.8.0_201]
>>>>            at
>>>> org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:357)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:498)
>>>>
>>>> ~[!/:3.3.2]
>>>>            at
>>>> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:353)
>>>> ~[!/:3.3.2]
>>>>            ... 43 more
>>>>
>>>> Aled
>>>>
>>>> [1]
>>>> https://lists.apache.org/thread.html/ead4351d187f7d7e7c257cb47f2490b3139d0de8d6fe15c43beea4d3%40%3Cdev.brooklyn.apache.org%3E
>>>>
>>>> [2] https://github.com/cloudsoft/winrm4j/
>>>>
>>>> [3] FIXME mailing list link
>>>>
>>>>

Re: IllegalAnnotationsException with CXF 3.3.2 in Karaf 4.2.7

Posted by Aled Sage <al...@gmail.com>.
Hi,

Thanks for this.

Not sure I follow though. Are you proposing we install cxf 3.3.4 instead 
of 3.3.2, into our Karaf 4.2.7 distro?

How does that fix the problem?

cxf-jaxws 3.3.4 depends on feature cxf-http 3.3.4, which depends on 
feature cxf-core 3.3.4, which depends on feature cxf-specs 3.3.4.

cxf-specs 3.3.4 depends on bundle jakarta.xml.bind-api (same as for 
3.3.2). That bundle is being installed automatically by inclusion of the 
feature. Unless we explicitly uninstall that bundle, we end up with 
javax.xml.bind.annotation coming from the two places. Because 
jakarta.xml.bind-api has the newer version, my bundle's import will use 
that one (if we don't specify a version range).

The relevant feature.xml file in Brooklyn [1] includes:

     <feature name="brooklyn-software-winrm" 
version="${project.version}" description="Brooklyn WinRM Software Entities">
<bundle>mvn:org.apache.brooklyn/brooklyn-software-winrm/${project.version}</bundle>
         <feature>brooklyn-core</feature>
         <bundle 
dependency="true">mvn:io.cloudsoft.windows/winrm4j/${winrm4j.version}</bundle>
         <bundle 
dependency="true">mvn:io.cloudsoft.windows/winrm4j-client/${winrm4j.version}</bundle>
<bundle>mvn:org.apache.brooklyn/brooklyn-karaf-httpcomponents-extension/${project.version}</bundle>
         <feature>cxf-jaxws</feature>
         <feature>cxf-http-async</feature>
         <feature>cxf-ws-addr</feature>
     </feature>

Other relevant CXF references in our feature.xml files are:

brooklyn-server/karaf/features/src/main/feature/feature.xml: 
<feature>cxf-jaxws</feature>
brooklyn-server/karaf/features/src/main/feature/feature.xml: 
<feature>cxf-http-async</feature>
brooklyn-server/karaf/features/src/main/feature/feature.xml: 
<feature>cxf-ws-addr</feature>
brooklyn-server/karaf/features/src/main/feature/feature.xml: <bundle 
dependency="true">mvn:org.apache.cxf/cxf-rt-rs-security-cors/${cxf.version}</bundle>
brooklyn-server/karaf/features/src/main/feature/feature.xml: <bundle 
dependency="true">mvn:org.apache.cxf/cxf-rt-frontend-jaxrs/${cxf.version}</bundle>
brooklyn-server/karaf/features/src/main/feature/feature.xml: <bundle 
dependency="true">mvn:org.apache.cxf.karaf/cxf-karaf-commands/${cxf.version}</bundle>

Aled

[1] 
https://github.com/apache/brooklyn-server/blob/master/karaf/features/src/main/feature/feature.xml#L229-L238 
(note that master has not been upgraded to CXF 3.3.2 yet; that's still 
being tested in my branch).


On 05/12/2019 08:31, Alexey Markevich wrote:
> Hi Aled,
>
> jakarta.xml.bind-api bundle installed as dependency from cxf-specs feature.
> In case step-by step setup its not activated:
>
>> feature:repo-add cxf 3.3.4
>> feature:install http cxf-jaxws
>> package:exports | grep javax.xml.bind.annotation
> javax.xml.bind.annotation.adapters                               |
> 2.2.8       | 0   | org.apache.felix.framework
> javax.xml.bind.annotation                                        |
> 2.2.8       | 0   | org.apache.felix.framework
>
> To avoid package version range
> javax.xml.bind.annotation;version="[2.3,3)"
>
> build your bunlde specifying 'javax.xml.bind.annotation' as
> Import-Package (without version range).
> In this case package from 'org.apache.felix.framework' bundle should be used.
>
> On 12/5/19, Aled Sage <al...@gmail.com> wrote:
>> Hi all,
>>
>> I'm a committer on the Apache Brooklyn [1] and the winrm4j [2] projects.
>>
>> We're upgrading Apache Brooklyn to Karaf 4.2.7 for the next release, and
>> have hit a big problem trying to upgrade CXF to 3.3.2 (from 3.2.8).
>>
>> We'd appreciate some help and advice for how to fix or work around this.
>>
>> There is a lot more details (including of the error investigation) in
>> this Apache Brooklyn email thread: [3].
>>
>> We're now getting an IllegalAnnotationsException, with the underlying
>> error:
>>
>> Two classes have the same XML type name
>> "{http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}objectFactory". Use
>> @XmlType.name and @XmlType.namespace to assign different names to them.
>>
>> It works when run outside of Karaf.
>>
>> Comparing the OSGi bundles and package exports/imports, I'm guessing the
>> underlying problem is that javax.xml.bind.annotation.XMLRegistry is now
>> coming from two places:
>>
>> package:exports | grep javax.xml.bind.annotation
>> javax.xml.bind.annotation.adapters    │ 2.2.8    │ 0   │
>> org.apache.felix.framework
>> javax.xml.bind.annotation.adapters    │ 2.3.2    │ 108 │
>> jakarta.xml.bind-api
>> javax.xml.bind.annotation             │ 2.2.8    │ 0   │
>> org.apache.felix.framework
>> javax.xml.bind.annotation             │ 2.3.2    │ 108 │
>> jakarta.xml.bind-api
>>
>> The jakarta.xml.bind-api bundle wasn't in our Karaf distro before - only
>> since we upgrade CXF (it comes from the feature cxf-specs, version 3.3.2).
>>
>> The winrm4j-client OSGi bundle is also being upgraded to use CXF 3.3.2 -
>> its package import is from jakarta.xml.bind-api.
>>
>> ---
>>
>> The stack trace is:
>>
>> 2019-12-03T11:44:16,468 wmhGA3U2-[ut059oi7tk,ltajipcuun] WARN  103
>> i.c.w.c.WinRmClient [ager-Ak6FHXbO-32] Error creating WinRm service with
>> mbean strategy (trying other strategies):
>> org.apache.cxf.service.factory.ServiceConstructionException
>> org.apache.cxf.service.factory.ServiceConstructionException: null
>>           at
>> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:355)
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:426)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
>>
>> ~[?:?]
>>           at
>> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
>>
>> ~[?:?]
>>           at
>> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:95)
>>
>> ~[!/:3.3.2]
>>           at
>> io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithBean(WinRmFactory.java:97)
>>
>> ~[!/:?]
>>           <snip>
>> Caused by:
>> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2
>> counts of IllegalAnnotationExceptions
>>           at
>> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
>>
>> ~[?:1.8.0_201]
>>           at
>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
>>
>> ~[?:1.8.0_201]
>>           at
>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
>>
>> ~[?:1.8.0_201]
>>           at
>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
>>
>> ~[?:1.8.0_201]
>>           at
>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
>>
>> ~[?:1.8.0_201]
>>           at
>> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
>>
>> ~[?:1.8.0_201]
>>           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> ~[?:1.8.0_201]
>>           at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>
>> ~[?:1.8.0_201]
>>           at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>
>> ~[?:1.8.0_201]
>>           at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201]
>>           at
>> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)
>> ~[?:1.8.0_201]
>>           at javax.xml.bind.ContextFinder.find(ContextFinder.java:396)
>> ~[?:1.8.0_201]
>>           at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
>> ~[?:1.8.0_201]
>>           at
>> org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:357)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:498)
>>
>> ~[!/:3.3.2]
>>           at
>> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:353)
>> ~[!/:3.3.2]
>>           ... 43 more
>>
>> Aled
>>
>> [1]
>> https://lists.apache.org/thread.html/ead4351d187f7d7e7c257cb47f2490b3139d0de8d6fe15c43beea4d3%40%3Cdev.brooklyn.apache.org%3E
>>
>> [2] https://github.com/cloudsoft/winrm4j/
>>
>> [3] FIXME mailing list link
>>
>>

Re: IllegalAnnotationsException with CXF 3.3.2 in Karaf 4.2.7

Posted by Alexey Markevich <bu...@gmail.com>.
Hi Aled,

jakarta.xml.bind-api bundle installed as dependency from cxf-specs feature.
In case step-by step setup its not activated:

> feature:repo-add cxf 3.3.4
> feature:install http cxf-jaxws
> package:exports | grep javax.xml.bind.annotation
javax.xml.bind.annotation.adapters                               |
2.2.8       | 0   | org.apache.felix.framework
javax.xml.bind.annotation                                        |
2.2.8       | 0   | org.apache.felix.framework

To avoid package version range
javax.xml.bind.annotation;version="[2.3,3)"

build your bunlde specifying 'javax.xml.bind.annotation' as
Import-Package (without version range).
In this case package from 'org.apache.felix.framework' bundle should be used.

On 12/5/19, Aled Sage <al...@gmail.com> wrote:
> Hi all,
>
> I'm a committer on the Apache Brooklyn [1] and the winrm4j [2] projects.
>
> We're upgrading Apache Brooklyn to Karaf 4.2.7 for the next release, and
> have hit a big problem trying to upgrade CXF to 3.3.2 (from 3.2.8).
>
> We'd appreciate some help and advice for how to fix or work around this.
>
> There is a lot more details (including of the error investigation) in
> this Apache Brooklyn email thread: [3].
>
> We're now getting an IllegalAnnotationsException, with the underlying
> error:
>
> Two classes have the same XML type name
> "{http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}objectFactory". Use
> @XmlType.name and @XmlType.namespace to assign different names to them.
>
> It works when run outside of Karaf.
>
> Comparing the OSGi bundles and package exports/imports, I'm guessing the
> underlying problem is that javax.xml.bind.annotation.XMLRegistry is now
> coming from two places:
>
> package:exports | grep javax.xml.bind.annotation
> javax.xml.bind.annotation.adapters    │ 2.2.8    │ 0   │
> org.apache.felix.framework
> javax.xml.bind.annotation.adapters    │ 2.3.2    │ 108 │
> jakarta.xml.bind-api
> javax.xml.bind.annotation             │ 2.2.8    │ 0   │
> org.apache.felix.framework
> javax.xml.bind.annotation             │ 2.3.2    │ 108 │
> jakarta.xml.bind-api
>
> The jakarta.xml.bind-api bundle wasn't in our Karaf distro before - only
> since we upgrade CXF (it comes from the feature cxf-specs, version 3.3.2).
>
> The winrm4j-client OSGi bundle is also being upgraded to use CXF 3.3.2 -
> its package import is from jakarta.xml.bind-api.
>
> ---
>
> The stack trace is:
>
> 2019-12-03T11:44:16,468 wmhGA3U2-[ut059oi7tk,ltajipcuun] WARN  103
> i.c.w.c.WinRmClient [ager-Ak6FHXbO-32] Error creating WinRm service with
> mbean strategy (trying other strategies):
> org.apache.cxf.service.factory.ServiceConstructionException
> org.apache.cxf.service.factory.ServiceConstructionException: null
>          at
> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:355)
> ~[!/:3.3.2]
>          at
> org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:426)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
>
> ~[?:?]
>          at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
>
> ~[?:?]
>          at
> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:95)
>
> ~[!/:3.3.2]
>          at
> io.cloudsoft.winrm4j.client.WinRmFactory.doCreateServiceWithBean(WinRmFactory.java:97)
>
> ~[!/:?]
>          <snip>
> Caused by:
> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2
> counts of IllegalAnnotationExceptions
>          at
> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
>
> ~[?:1.8.0_201]
>          at
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
>
> ~[?:1.8.0_201]
>          at
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
>
> ~[?:1.8.0_201]
>          at
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
>
> ~[?:1.8.0_201]
>          at
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
>
> ~[?:1.8.0_201]
>          at
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
>
> ~[?:1.8.0_201]
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> ~[?:1.8.0_201]
>          at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> ~[?:1.8.0_201]
>          at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> ~[?:1.8.0_201]
>          at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201]
>          at
> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)
> ~[?:1.8.0_201]
>          at javax.xml.bind.ContextFinder.find(ContextFinder.java:396)
> ~[?:1.8.0_201]
>          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
> ~[?:1.8.0_201]
>          at
> org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:357)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:498)
>
> ~[!/:3.3.2]
>          at
> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:353)
> ~[!/:3.3.2]
>          ... 43 more
>
> Aled
>
> [1]
> https://lists.apache.org/thread.html/ead4351d187f7d7e7c257cb47f2490b3139d0de8d6fe15c43beea4d3%40%3Cdev.brooklyn.apache.org%3E
>
> [2] https://github.com/cloudsoft/winrm4j/
>
> [3] FIXME mailing list link
>
>