You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by criedluv <Ke...@issinc.com> on 2014/12/30 22:20:16 UTC

java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

I'm using:

CXF: 2.7.12 
Spring: 3.2.5.RELEASE 
JAXB
JAXWS/JAXRS 

I'm getting the above error in my JAXRS prototype endpoint method
implementation because the method argument, List<Customer> is instead
unmarshalled to  List<ElementNSImpl>. I get the exception when accessing a
member of the List.

When running JAXWS to the same method all is well.

I have a large number of interface methods in my target project with
implementations supporting JAXWS just fine. I'm adding JAXRS support. I want
to make sure I use the right approach the first time. 

Do I need to provide additional jaxb-provider configuration for each method
using input and/or output collections? If so, that's a lot of additional
configuration. Can you please point me to the best example?

Here is my prototype JAXWS / JAXRS config: 


<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jaxrs="http://cxf.apache.org/jaxrs"
      xmlns:jaxws="http://cxf.apache.org/jaxws"
      xmlns:soap="http://cxf.apache.org/bindings/soap"
      xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
         http://cxf.apache.org/jaxrs
         http://cxf.apache.org/schemas/jaxrs.xsd
         http://cxf.apache.org/jaxws
         http://cxf.apache.org/schemas/jaxws.xsd">

     <import resource="classpath:META-INF/cxf/cxf.xml" />

     <jaxrs:server address="/jaxrs" 
                  
modelRef="classpath:/data/model/CustomerService-jaxrs.xml">
       <jaxrs:serviceBeans>
         <ref bean="customer-bean"/>
       </jaxrs:serviceBeans>
       <jaxrs:providers>
         <ref bean="jaxb-provider"/>
         <bean class="service.description.NoCustomerExceptionMapper"/>
       </jaxrs:providers>		   
     </jaxrs:server>

     <bean id="jaxb-provider"
class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
        <property name="unmarshallAsJaxbElement" value="true"/>
        <property name="marshallAsJaxbElement" value="true"/>
     </bean>

     <jaxws:endpoint implementor="#customer-bean" address="/jaxws"/>      

     <bean id="customer-bean"
class="service.description.CustomerServiceImpl"/>
</beans>



thanks in advance.






--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by criedluv <Ke...@issinc.com>.
criedluv wrote
> This is very likely a config issue on my part.
> 
> I went to 2.17.14 which the example includes. but doesn't seem to fix the
> issue.
> 
> See my readme along with sample app test case. Let me know if you need
> anything.
> 
> thank you.
> examples.zip <http://cxf.547215.n5.nabble.com/file/n5752828/examples.zip>  


Just to clarify my earlier post... I tried version CXF 2.7.14, but didn't
see any change.



--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5752843.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by criedluv <Ke...@issinc.com>.
criedluv wrote
> I'm really perplexed by the above error and not sure how to diagnose.
> 
> I went from CXF 3.0.3 to 3.1.0-SNAPSHOT hoping this might resolve it...
> but no luck. Here is error, jaxb and cxf jars. I'm no longer performing
> the previous jar exclusion.

A couple of questions come to mind: 

1) are the versions of these two jars compatible with CXF 3.1.0-SNAPSHOT?


[INFO] +- org.apache.cxf.xjc-utils:cxf-xjc-runtime:jar:3.0.3:compile 
[INFO] |        \- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile 


2) Is the above CXF version compatible with Spring 3.2.5?

thank you.



--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5753037.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by criedluv <Ke...@issinc.com>.
Sergey Beryozkin wrote
> Sorry, first time I'm seeing this exception, indeed something to do with 
> the dependencies.

I'm really perplexed by the above error and not sure how to diagnose.

I went from CXF 3.0.3 to 3.1.0-SNAPSHOT hoping this might resolve it... but
no luck. Here is error, jaxb and cxf jars. I'm no longer performing the
previous jar exclusion.



java.lang.NoSuchFieldError: REFLECTION

com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:89)

com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:431)

com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:288)

com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1111)
	com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
	com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:606)
	javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
	javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
	javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
	javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)

org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:347)

org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345)
	java.security.AccessController.doPrivileged(Native Method)

org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:345)

org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.getContext(AbstractBeanDefinitionParser.java:326)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElementToJaxbProperty(AbstractBeanDefinitionParser.java:352)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElementToJaxbProperty(AbstractBeanDefinitionParser.java:299)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElementToJaxbProperty(AbstractBeanDefinitionParser.java:276)

org.apache.cxf.transport.http.spring.HttpDestinationBeanDefinitionParser.doParse(HttpDestinationBeanDefinitionParser.java:39)

org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)

org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)

org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)

org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)

org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)

org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195)

org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)

org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)

org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)

org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)

org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)

org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)

org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)

org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
	org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)

org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)

org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)

org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)

org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)

org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)

java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:744)





[INFO] |  \- org.apache.cxf:cxf-rt-bindings-soap:jar:3.1.0-SNAPSHOT:compile
[INFO] |     +- org.apache.cxf:cxf-rt-wsdl:jar:3.1.0-SNAPSHOT:compile
[INFO] |     \-
org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.1.0-SNAPSHOT:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:3.1.0-SNAPSHOT:compile
[INFO] |  +- org.apache.cxf:cxf-core:jar:3.1.0-SNAPSHOT:compile
[INFO] |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:3.1.0-SNAPSHOT:compile
[INFO] |  +-
org.apache.cxf:cxf-rt-frontend-simple:jar:3.1.0-SNAPSHOT:compile
[INFO] |  \- org.apache.cxf:cxf-rt-ws-addr:jar:3.1.0-SNAPSHOT:compile
[INFO] |     \- org.apache.cxf:cxf-rt-ws-policy:jar:3.1.0-SNAPSHOT:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:3.1.0-SNAPSHOT:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-jms:jar:3.1.0-SNAPSHOT:test
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:3.1.0-SNAPSHOT:compile
[INFO] +- org.apache.cxf.xjc-utils:cxf-xjc-runtime:jar:3.0.3:compile


[INFO] |        \- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile






--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5753036.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by Sergey Beryozkin <sb...@gmail.com>.
Sorry, first time I'm seeing this exception, indeed something to do with 
the dependencies.

Sergey
On 14/01/15 02:13, criedluv wrote:
> formatted dependencyTree:
>
> dependencyTree.txt
> <http://cxf.547215.n5.nabble.com/file/n5753012/dependencyTree.txt>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5753012.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by criedluv <Ke...@issinc.com>.
formatted dependencyTree:

dependencyTree.txt
<http://cxf.547215.n5.nabble.com/file/n5753012/dependencyTree.txt>  



--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5753012.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by criedluv <Ke...@issinc.com>.
Sergey Beryozkin wrote
> Hi, sorry for a delay,
> 
> I have it working with 3.1.0-SNAPSHOT (should also with 3.0.3).
> I did reproduce this error with CXF 2.7.14. A fix must've been quite 
> sensitive given that it did not make it to CXF 2.7.x.
> In general, dealing with explicit collections is problematic  IMHO for 
> JAX-RS services given that the interoperability decreases though might 
> work in some cases when diff JAX-RS stacks are used on two ends.
> 
> The explicit collections of XmlRootElement-annotated beans is supported 
> in CXF 2.7.x too, but the collections of XmlType only elements is not.
> Please try CXF 3.0.3 or, if possible, get the beans wrapping the 
> collections generated instead - this is done automatically for JAXWS but 
> not for JAX-RS. You can get JAXB generating such beans by using the 
> anonymous complex types and possibly other options...
> 
> Sergey

I tried CXF 3.0.3 and 3.0.2 with the sample and it works great. 

I tried them with my target application, but threw the error below upon war
deployment:

I'm using jaxb dependencies as shown in the attached dependency tree. The
default jaxb used by Cxf 3.0.* is 2.2.10-b140310.1920 (which failed with a
similar error) based on a post I read. The same post suggested excluding it
and manually using 2.1.14 which is what I'm using now and is failing.

thank you.





root cause 
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from URL
[jndi:/localhost/iw/WEB-INF/cxf-servlet.xml]; nested exception is
java.lang.NoSuchFieldError: REFLECTION

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)

org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)

org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)

org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)

org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)

org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)

org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
	org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)

org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)

org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)

org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)

org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)

org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)

java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:744)



root cause 
java.lang.NoSuchFieldError: REFLECTION

com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:93)

com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:464)

com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:310)

com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:146)

com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1169)
	com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:606)
	javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
	javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
	javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
	javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)

org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:347)

org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345)
	java.security.AccessController.doPrivileged(Native Method)

org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:345)

org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.getContext(AbstractBeanDefinitionParser.java:320)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElementToJaxbProperty(AbstractBeanDefinitionParser.java:346)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElementToJaxbProperty(AbstractBeanDefinitionParser.java:293)

org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElementToJaxbProperty(AbstractBeanDefinitionParser.java:270)

org.apache.cxf.transport.http.spring.HttpDestinationBeanDefinitionParser.doParse(HttpDestinationBeanDefinitionParser.java:39)

org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)

org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)

org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)

org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)

org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)

org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195)

org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)

org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)

org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)

org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)

org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)

org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)

org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)

org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)

org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
	org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)

org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)

org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)

org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)

org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)

org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)

java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:744)





dependencyTree.dependencyTree
<http://cxf.547215.n5.nabble.com/file/n5753011/dependencyTree.dependencyTree>  





--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5753011.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi, sorry for a delay,

I have it working with 3.1.0-SNAPSHOT (should also with 3.0.3).
I did reproduce this error with CXF 2.7.14. A fix must've been quite 
sensitive given that it did not make it to CXF 2.7.x.
In general, dealing with explicit collections is problematic  IMHO for 
JAX-RS services given that the interoperability decreases though might 
work in some cases when diff JAX-RS stacks are used on two ends.

The explicit collections of XmlRootElement-annotated beans is supported 
in CXF 2.7.x too, but the collections of XmlType only elements is not.
Please try CXF 3.0.3 or, if possible, get the beans wrapping the 
collections generated instead - this is done automatically for JAXWS but 
not for JAX-RS. You can get JAXB generating such beans by using the 
anonymous complex types and possibly other options...

Sergey

On 06/01/15 18:32, criedluv wrote:
> Sergey Beryozkin wrote
>> Can you provide a test case please ?
>> Unmarshalling a payload into an explicit collection is tested in CXF
>> JAX-RS system tests but I need to have a test available to investigate
>> further.
>> Can you also try CXF 2.7.14 ? The issue may have been fixed there
>> Cheers, Sergey
>>
>
> Sergey, I attached a CXF JAXRS/WS client and endpoint. The client first
> calls the method using WS in question and successfully returns. It then
> calls the same method using RS. Within the invoked, called method, the list
> in question arrives with objects indicating _the_ unmarshalling issue.
>
> This is very likely a config issue on my part.
>
> I went to 2.17.14 which the example includes. but doesn't seem to fix the
> issue.
>
> See my readme along with sample app test case. Let me know if you need
> anything.
>
> thank you.
>
> examples.zip <http://cxf.547215.n5.nabble.com/file/n5752828/examples.zip>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5752828.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by criedluv <Ke...@issinc.com>.
Sergey Beryozkin wrote
> Can you provide a test case please ?
> Unmarshalling a payload into an explicit collection is tested in CXF 
> JAX-RS system tests but I need to have a test available to investigate 
> further.
> Can you also try CXF 2.7.14 ? The issue may have been fixed there
> Cheers, Sergey
> 

Sergey, I attached a CXF JAXRS/WS client and endpoint. The client first
calls the method using WS in question and successfully returns. It then
calls the same method using RS. Within the invoked, called method, the list
in question arrives with objects indicating _the_ unmarshalling issue.

This is very likely a config issue on my part.

I went to 2.17.14 which the example includes. but doesn't seem to fix the
issue.

See my readme along with sample app test case. Let me know if you need
anything.

thank you.

examples.zip <http://cxf.547215.n5.nabble.com/file/n5752828/examples.zip>  



--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756p5752828.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to XXXXX

Posted by Sergey Beryozkin <sb...@gmail.com>.
Can you provide a test case please ?
Unmarshalling a payload into an explicit collection is tested in CXF 
JAX-RS system tests but I need to have a test available to investigate 
further.
Can you also try CXF 2.7.14 ? The issue may have been fixed there
Cheers, Sergey



On 30/12/14 21:20, criedluv wrote:
> I'm using:
>
> CXF: 2.7.12
> Spring: 3.2.5.RELEASE
> JAXB
> JAXWS/JAXRS
>
> I'm getting the above error in my JAXRS prototype endpoint method
> implementation because the method argument, List<Customer> is instead
> unmarshalled to  List<ElementNSImpl>. I get the exception when accessing a
> member of the List.
>
> When running JAXWS to the same method all is well.
>
> I have a large number of interface methods in my target project with
> implementations supporting JAXWS just fine. I'm adding JAXRS support. I want
> to make sure I use the right approach the first time.
>
> Do I need to provide additional jaxb-provider configuration for each method
> using input and/or output collections? If so, that's a lot of additional
> configuration. Can you please point me to the best example?
>
> Here is my prototype JAXWS / JAXRS config:
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>        xmlns:jaxws="http://cxf.apache.org/jaxws"
>        xmlns:soap="http://cxf.apache.org/bindings/soap"
>        xsi:schemaLocation="
>           http://www.springframework.org/schema/beans
>           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>           http://cxf.apache.org/jaxrs
>           http://cxf.apache.org/schemas/jaxrs.xsd
>           http://cxf.apache.org/jaxws
>           http://cxf.apache.org/schemas/jaxws.xsd">
>
>       <import resource="classpath:META-INF/cxf/cxf.xml" />
>
>       <jaxrs:server address="/jaxrs"
>
> modelRef="classpath:/data/model/CustomerService-jaxrs.xml">
>         <jaxrs:serviceBeans>
>           <ref bean="customer-bean"/>
>         </jaxrs:serviceBeans>
>         <jaxrs:providers>
>           <ref bean="jaxb-provider"/>
>           <bean class="service.description.NoCustomerExceptionMapper"/>
>         </jaxrs:providers>		
>       </jaxrs:server>
>
>       <bean id="jaxb-provider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
>          <property name="unmarshallAsJaxbElement" value="true"/>
>          <property name="marshallAsJaxbElement" value="true"/>
>       </bean>
>
>       <jaxws:endpoint implementor="#customer-bean" address="/jaxws"/>
>
>       <bean id="customer-bean"
> class="service.description.CustomerServiceImpl"/>
> </beans>
>
>
>
> thanks in advance.
>
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-com-sun-org-apache-xerces-internal-dom-ElementNSImpl-cannot-be-cast-to-X-tp5752756.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>