Daniel, can you please look into this issue. :-(

Thanks Glen for your response.I believe your BasicFault class is simple POJO 
which is not inheriting from java Exception class, Right ? Can you please 
confirm it.

I have another issue.

My web service calls some other business functions which throws exceptions. 
The business exceptions has its own hierarchy so if I pass them to client as it 
is then client gets only the child class elements.

So now suggestion is that I wrap the exception object in fault but I believe 
the Fault can wrap only POJOs and not other exception object.

Let me write a code to explain

Business Model Exceptions

class BusinessParentException  extends Exception {

...........

}



class BusinessChildException extends BsuinessParentException {

..........


}



-------------------------------------------------------------------------------------------------------

Service Layer Exception POJO Hierarchy 

class ServiceParentException { // note it is not extending Exception 
...........
}

class ServiceChildException extends ServiceParentException {
..........

}


class CustomException {
    ServiceChildException ce ;
     ........

}



Service Method

public void foo() throws CustomException {

   try {
       calling business function
   } catch (BusinessChildException e ) {
      //convert e (of type BusinessChildException) to f of type 
ServiceChildException    
      throw new CustomException(" XXX " , f ) ;
  }
}
  }

If I dont convert BusinessChildException to ServiceChildException and try to 
wrap it in CustomException then I get following Exception

Caused by: org.apache.cxf.interceptor.Fault: Could not find JAXB information 
for bean class exceptions.BusinessChildException in context.   Make sure it 
follows JAXB conventions.
    at 
org.apache.cxf.jaxb.JAXBSchemaInitializer.end(JAXBSchemaInitializer.java:295)
    at 
org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceModelVisitor.java:124)
    at 
org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.java:74)
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:366)
    at 
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:345)
    at 
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:513)
    at 
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:396)
    at 
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
    at 
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:163)
    at 
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
    at 
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
    at 
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
    at 
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:115)
    ... 39 more

It looks like that you can't wrap object of type Exception in any exception 
that is thrown over the wire. This would mean I have to create duplicate 
hierarchy of exception pojo just for web services. Is there any way I can avoid 
it and wrap exception object in Fault thrown over wire.

Thanks,

Petr







--- On Fri, 3/6/09, Glen Mazza <[email protected]> wrote:
From: Glen Mazza <[email protected]>
Subject: Re: Exception Inheritance Model
To: [email protected]
Date: Friday, March 6, 2009, 1:44 AM

FWIW, this is what I did when I had several types of different error messages
to handle:
http://www.jroller.com/gmazza/entry/database_crud_actions_with_web

HTH,
Glen


Petr V. wrote:
> 
> Any one please ?
> 
> Thanks,
> 
> Petr
> 
> --- On Wed, 3/4/09, Petr V. <[email protected]> wrote:
> From: Petr V. <[email protected]>
> Subject: Exception Inheritance Model
> To: [email protected]
> Date: Wednesday, March 4, 2009, 11:29 PM
> 
> I have inheritance model in exception hierarchy but published wsdl via CXF
> does
> not show that.
> 
> I did lil google and found that it is as per spec
> 
> Dan replied below on following thread 
> 
>
http://mail-archives.apache.org/mod_mbox/cxf-users/200803.mbox/%[email protected]%3e
> 
> "As Glen mentioned, this is completely per spec.   
> 
> You can work around it SLIGHTLY by refactoring your exceptions to store 
> all their data in JAXB specified java beans (grabbed via getFaultInfo()) 
> that implement the same heiarchy.   That said, when you run wsdl2java on 
> the wsdl to generate code from it, that heiarchy would not be honored in 
> the exceptions themselves. 
> 
> In anycase, this is all per spec."
> So this raises new question. Since I am writing java first so all my
> methods
> throw the top exception class so in case if I need to throw some sub
> classes, I
> wont have to change function signature. But if service publish does not
> maintain
> hierarchy model so what would happen if some exception is thrown from
> service
> which is actuall ysub class of super class but not specified in wsdl,
> Crash ?
> Run Time Exception ?
> 
> class TopException {
> }
> 
> class subException1 extends TopException {
> }
> 
> class subException2 extends TopException {
> 
> }
> 
> Method in service is
> 
> public void foo() throws subException1 , TopException{
> .....
> }
> 
> So generated wsdl would show that two exceptions could be thrown.
> 
> So far so good but as we know that subException2 is inherited from
> TopException1 so there is no stopping for throwing it from foo()
> 
> So what if client calls service method foo() and foo() throws
> subException2
> (java compiler wont complain as well as outside web services, code would
> work
> fine) but wsdl and generated proxy won't have no idea that
subException2
> is
> inherited from TopException1 so would it crash at run time?
> 
> Does it mean that I need to explictly define every exception that could be
> thrown from web services so it can show up in wsdl and should not rely on
> inheritance model of exception. It would mean that I just flatten my
> exception
> model and live with that :-(. 
> 
> Is my understanding coprrect ? Am I missin gsoem thing?
> 
> Any help would be appreciated to clarify my understanding and how to avoid
> the
> current situation.
> 
> Thanks,
> 
> Petr
> 
> 
> 
>       
> 
> 
>       
> 

-- 
View this message in context:
http://www.nabble.com/Exception-Inheritance-Model-tp22336256p22360240.html
Sent from the cxf-user mailing list archive at Nabble.com.




      

Reply via email to