You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2008/10/01 19:58:52 UTC

Re: xmlbean binding can not handle throws exception

Quick question:

the TestException exception, does that "look like" a JAX-WS generated 
exception.   Basically, does it have a "getFaultInfo()" method that 
returns the XMLBeans generated type for the fault?    If not, can you 
try that?   (also will need the constructors that take that bean)

I THINK that will work (not 100% sure though).

Either way, thanks for logging the bug.   It does need to be fixed.  I'm 
just trying to provide a workaround.

Dan




On Tuesday 30 September 2008, quzhe wrote:
> hi,All:
>    I use xmlbeans binding, when I write this service, it is working:
> @WebMethod(operationName="insertSysaddresstype")
> 	@WebResult(name="InsertSysaddresstypeResponse")InsertSysaddresstypeRe
>sponse insert(@WebParam(name="InsertSysaddresstypeParam")
> InsertSysaddresstypeParamDocument.InsertSysaddresstypeParam body) ;
>
> but when I throw a exception:
> @WebMethod(operationName="insertSysaddresstype")
> 	@WebResult(name="InsertSysaddresstypeResponse")InsertSysaddresstypeRe
>sponse insert(@WebParam(name="InsertSysaddresstypeParam")
> InsertSysaddresstypeParamDocument.InsertSysaddresstypeParam body)
> throws TestException;
>
> cxf will have a nullpoint exception:
>
>
> Caused by: java.lang.NullPointerException
>         at
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.mapClass(XmlBeansSc
> hemaInitializer.java:165)
>         at
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.checkForExistence(X
> mlBeansSchemaInitializer.java:217)
>         at
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.begin(XmlBeansSchem
> aInitializer.java:142)
>         at
> org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceMode
> lVisitor.java:120)
>         at
> org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.j
> ava:74)
>         at
> org.apache.cxf.xmlbeans.XmlBeansDataBinding.initialize(XmlBeansDataBi
> nding.java:102)
>         at
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServ
> iceFromClass(ReflectionServiceFactoryBean.java:345)
>         at
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFrom
> Class(JaxWsServiceFactoryBean.java:513)
>
>
>
> How to do it here?
>
> thank you!



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: xmlbean binding can not handle throws exception

Posted by quzhe <zh...@hotmail.com>.
Thank you for your reply!

I try to add getFaultInfo() into exception, now that nullpointexception will
not happen.

but when I write another test with localTransport, here have a new
exception:

my test:

param.setUnid(2L);
		try {
		
assertEquals("value",testLocalServiceClient.testMethod(param).getValue());
		} catch (TestException e) {
			assertEquals("fault", e.getFaultInfo());
			assertEquals("fault", e.getMessage());
			
		}

service impl:
if(body.getUnid()==2L){
			TestException te =  new TestException("fault");
			SystemFaultDocument document = SystemFaultDocument.Factory.newInstance();
			SystemFault sf = document.addNewSystemFault();
			sf.setValue("fault");
			te.setFaultInfo(document);
			throw te;
		}



I get another nullpointexception:
信息: Application has thrown exception, unwinding now:
com.mycompany.app.TestException: fault
2008-10-2 12:31:35 org.apache.cxf.jaxws.interceptors.WebFaultOutInterceptor
handleMessage
警告: Exception occurred while writing fault.
java.lang.NullPointerException
	at org.apache.cxf.xmlbeans.DataWriterImpl.write(DataWriterImpl.java:60)
	at
org.apache.cxf.xmlbeans.NodeDataWriterImpl.write(NodeDataWriterImpl.java:47)
	at
org.apache.cxf.xmlbeans.NodeDataWriterImpl.write(NodeDataWriterImpl.java:34)
	at
org.apache.cxf.jaxws.interceptors.WebFaultOutInterceptor.handleMessage(WebFaultOutInterceptor.java:112)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:260)
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
	at
org.apache.cxf.transport.local.LocalConduit$1$1.run(LocalConduit.java:132)
	at java.lang.Thread.run(Unknown Source)
2008-10-2 12:31:35 com.sun.xml.messaging.saaj.soap.impl.FaultImpl
setFaultCode
严重: SAAJ0140: No NamespaceURI, SOAP requires faultcode content to be a QName


 





dkulp wrote:
> 
> 
> Quick question:
> 
> the TestException exception, does that "look like" a JAX-WS generated 
> exception.   Basically, does it have a "getFaultInfo()" method that 
> returns the XMLBeans generated type for the fault?    If not, can you 
> try that?   (also will need the constructors that take that bean)
> 
> I THINK that will work (not 100% sure though).
> 
> Either way, thanks for logging the bug.   It does need to be fixed.  I'm 
> just trying to provide a workaround.
> 
> Dan
> 
> 
> 
> 
> On Tuesday 30 September 2008, quzhe wrote:
>> hi,All:
>>    I use xmlbeans binding, when I write this service, it is working:
>> @WebMethod(operationName="insertSysaddresstype")
>> 	@WebResult(name="InsertSysaddresstypeResponse")InsertSysaddresstypeRe
>>sponse insert(@WebParam(name="InsertSysaddresstypeParam")
>> InsertSysaddresstypeParamDocument.InsertSysaddresstypeParam body) ;
>>
>> but when I throw a exception:
>> @WebMethod(operationName="insertSysaddresstype")
>> 	@WebResult(name="InsertSysaddresstypeResponse")InsertSysaddresstypeRe
>>sponse insert(@WebParam(name="InsertSysaddresstypeParam")
>> InsertSysaddresstypeParamDocument.InsertSysaddresstypeParam body)
>> throws TestException;
>>
>> cxf will have a nullpoint exception:
>>
>>
>> Caused by: java.lang.NullPointerException
>>         at
>> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.mapClass(XmlBeansSc
>> hemaInitializer.java:165)
>>         at
>> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.checkForExistence(X
>> mlBeansSchemaInitializer.java:217)
>>         at
>> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.begin(XmlBeansSchem
>> aInitializer.java:142)
>>         at
>> org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceMode
>> lVisitor.java:120)
>>         at
>> org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.j
>> ava:74)
>>         at
>> org.apache.cxf.xmlbeans.XmlBeansDataBinding.initialize(XmlBeansDataBi
>> nding.java:102)
>>         at
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServ
>> iceFromClass(ReflectionServiceFactoryBean.java:345)
>>         at
>> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFrom
>> Class(JaxWsServiceFactoryBean.java:513)
>>
>>
>>
>> How to do it here?
>>
>> thank you!
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer, IONA
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/xmlbean-binding-can-not-handle-throws-exception-tp19735873p19773237.html
Sent from the cxf-user mailing list archive at Nabble.com.