You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Arul Dhesiaseelan <ar...@fluxcorp.com> on 2008/06/23 22:45:08 UTC

configuring custom JAXB annotation readers in CXF

Hi,

One of my bean method returns IOException. When I start my web service, 
I get "java.lang.StackTraceElement does not have a no-arg default 
constructor".

I see this issue could be overcome using JAXB introductions discussed in 
this thread: http://forums.java.net/jive/thread.jspa?messageID=282016 
which allows to add XmlTransient annotations to java.lang.Exception class.

How would I configure CXF to invoke these custom JAXB annotation readers 
during runtime? I am not sure as to how this custom JAXBContext could be 
created to override CXF JAXBContext.

Please clarify.

Thank you,
Arul





Re: configuring custom JAXB annotation readers in CXF

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Thanks Benson.

I will try this first.

-Arul

Benson Margulies wrote:
> Call functions on the JAXBDataBinding object. Pass that object as
> setDatabinding on the SFB.
>
> On Tue, Jun 24, 2008 at 7:40 PM, Arul Dhesiaseelan <ar...@fluxcorp.com>
> wrote:
>
>   
>> Thanks Dan.
>>
>> I am using JaxWsServerFactoryBean to create my service. Is it possible to
>> set these JAXB parameters in the server factory?
>>
>> Basically, I need to set these info on the CXF JAXBContext.
>>
>> // initialize custom reader
>> TransientAnnotationReader reader = new TransientAnnotationReader();
>> reader.addTransientField(Throwable.class.getDeclaredField("stackTrace"));
>>
>> reader.addTransientMethod(Throwable.class.getDeclaredMethod("getStackTrace"));
>>
>> // initialize JAXB context
>> Map<String, Object> jaxbConfig = new HashMap<String, Object>();
>> jaxbConfig.put(JAXBRIContext.ANNOTATION_READER, reader);
>> String yourPackages = "deltix.qsrv.pub:deltix.qsrv.comm.xml:";
>> JAXBContext ctx = JAXBContext.newInstance (yourPackages,
>> TransientAnnotationReader.class.getClassLoader(), jaxbConfig);
>>
>> I am more interested in setting these on JAXBDataBinding object through CXF
>> API instead using spring config.
>>
>> Appreciate your help on this issue.
>>
>> -Arul
>>
>> Daniel Kulp wrote:
>>
>>     
>>> I just realized this is covered in the docs:
>>>
>>> http://cwiki.apache.org/CXF20DOC/jaxb.html
>>>
>>>
>>> Dan
>>>
>>>
>>>
>>> On Jun 23, 2008, at 9:22 PM, Daniel Kulp wrote:
>>>
>>>
>>>       
>>>> The JAXBDataBinding object has maps for both contextProperties and
>>>> marshallerProperties that can be configured via spring configuration.
>>>> Unfortunately, it doesn't look like we have an example of configuring via
>>>> spring, just via the apis.  :-(
>>>>
>>>> Dan
>>>>
>>>>
>>>>
>>>> On Jun 23, 2008, at 4:45 PM, Arul Dhesiaseelan wrote:
>>>>
>>>>  Hi,
>>>>         
>>>>> One of my bean method returns IOException. When I start my web service,
>>>>> I get "java.lang.StackTraceElement does not have a no-arg default
>>>>> constructor".
>>>>>
>>>>> I see this issue could be overcome using JAXB introductions discussed in
>>>>> this thread: http://forums.java.net/jive/thread.jspa?messageID=282016which allows to add XmlTransient annotations to java.lang.Exception class.
>>>>>
>>>>> How would I configure CXF to invoke these custom JAXB annotation readers
>>>>> during runtime? I am not sure as to how this custom JAXBContext could be
>>>>> created to override CXF JAXBContext.
>>>>>
>>>>> Please clarify.
>>>>>
>>>>> Thank you,
>>>>> Arul
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> ---
>>>> Daniel Kulp
>>>> dkulp@apache.org
>>>> http://www.dankulp.com/blog
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>         
>>> ---
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>>
>>>
>>>
>>>
>>>
>>> ________________________________
>>> Scanned by MessageLabs for Flux
>>> ________________________________
>>>
>>>       
>>     
>
>
> ________________________________
> Scanned by MessageLabs for Flux
> ________________________________
>   


Re: configuring custom JAXB annotation readers in CXF

Posted by Benson Margulies <bi...@gmail.com>.
Call functions on the JAXBDataBinding object. Pass that object as
setDatabinding on the SFB.

On Tue, Jun 24, 2008 at 7:40 PM, Arul Dhesiaseelan <ar...@fluxcorp.com>
wrote:

> Thanks Dan.
>
> I am using JaxWsServerFactoryBean to create my service. Is it possible to
> set these JAXB parameters in the server factory?
>
> Basically, I need to set these info on the CXF JAXBContext.
>
> // initialize custom reader
> TransientAnnotationReader reader = new TransientAnnotationReader();
> reader.addTransientField(Throwable.class.getDeclaredField("stackTrace"));
>
> reader.addTransientMethod(Throwable.class.getDeclaredMethod("getStackTrace"));
>
> // initialize JAXB context
> Map<String, Object> jaxbConfig = new HashMap<String, Object>();
> jaxbConfig.put(JAXBRIContext.ANNOTATION_READER, reader);
> String yourPackages = "deltix.qsrv.pub:deltix.qsrv.comm.xml:";
> JAXBContext ctx = JAXBContext.newInstance (yourPackages,
> TransientAnnotationReader.class.getClassLoader(), jaxbConfig);
>
> I am more interested in setting these on JAXBDataBinding object through CXF
> API instead using spring config.
>
> Appreciate your help on this issue.
>
> -Arul
>
> Daniel Kulp wrote:
>
>>
>> I just realized this is covered in the docs:
>>
>> http://cwiki.apache.org/CXF20DOC/jaxb.html
>>
>>
>> Dan
>>
>>
>>
>> On Jun 23, 2008, at 9:22 PM, Daniel Kulp wrote:
>>
>>
>>> The JAXBDataBinding object has maps for both contextProperties and
>>> marshallerProperties that can be configured via spring configuration.
>>> Unfortunately, it doesn't look like we have an example of configuring via
>>> spring, just via the apis.  :-(
>>>
>>> Dan
>>>
>>>
>>>
>>> On Jun 23, 2008, at 4:45 PM, Arul Dhesiaseelan wrote:
>>>
>>>  Hi,
>>>>
>>>> One of my bean method returns IOException. When I start my web service,
>>>> I get "java.lang.StackTraceElement does not have a no-arg default
>>>> constructor".
>>>>
>>>> I see this issue could be overcome using JAXB introductions discussed in
>>>> this thread: http://forums.java.net/jive/thread.jspa?messageID=282016which allows to add XmlTransient annotations to java.lang.Exception class.
>>>>
>>>> How would I configure CXF to invoke these custom JAXB annotation readers
>>>> during runtime? I am not sure as to how this custom JAXBContext could be
>>>> created to override CXF JAXBContext.
>>>>
>>>> Please clarify.
>>>>
>>>> Thank you,
>>>> Arul
>>>>
>>>>
>>>>
>>>>
>>>>
>>> ---
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>>
>>>
>>>
>>>
>>>
>> ---
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>>
>>
>>
>>
>>
>> ________________________________
>> Scanned by MessageLabs for Flux
>> ________________________________
>>
>
>

Re: configuring custom JAXB annotation readers in CXF

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Thanks Dan.

I am using JaxWsServerFactoryBean to create my service. Is it possible 
to set these JAXB parameters in the server factory?

Basically, I need to set these info on the CXF JAXBContext.

// initialize custom reader
TransientAnnotationReader reader = new TransientAnnotationReader();
reader.addTransientField(Throwable.class.getDeclaredField("stackTrace"));
reader.addTransientMethod(Throwable.class.getDeclaredMethod("getStackTrace"));

// initialize JAXB context
Map<String, Object> jaxbConfig = new HashMap<String, Object>();
jaxbConfig.put(JAXBRIContext.ANNOTATION_READER, reader);
String yourPackages = "deltix.qsrv.pub:deltix.qsrv.comm.xml:";
JAXBContext ctx = JAXBContext.newInstance (yourPackages, 
TransientAnnotationReader.class.getClassLoader(), jaxbConfig);

I am more interested in setting these on JAXBDataBinding object through 
CXF API instead using spring config.

Appreciate your help on this issue.

-Arul

Daniel Kulp wrote:
>
> I just realized this is covered in the docs:
>
> http://cwiki.apache.org/CXF20DOC/jaxb.html
>
>
> Dan
>
>
>
> On Jun 23, 2008, at 9:22 PM, Daniel Kulp wrote:
>
>>
>> The JAXBDataBinding object has maps for both contextProperties and 
>> marshallerProperties that can be configured via spring 
>> configuration.   Unfortunately, it doesn't look like we have an 
>> example of configuring via spring, just via the apis.  :-(
>>
>> Dan
>>
>>
>>
>> On Jun 23, 2008, at 4:45 PM, Arul Dhesiaseelan wrote:
>>
>>> Hi,
>>>
>>> One of my bean method returns IOException. When I start my web 
>>> service, I get "java.lang.StackTraceElement does not have a no-arg 
>>> default constructor".
>>>
>>> I see this issue could be overcome using JAXB introductions 
>>> discussed in this thread: 
>>> http://forums.java.net/jive/thread.jspa?messageID=282016 which 
>>> allows to add XmlTransient annotations to java.lang.Exception class.
>>>
>>> How would I configure CXF to invoke these custom JAXB annotation 
>>> readers during runtime? I am not sure as to how this custom 
>>> JAXBContext could be created to override CXF JAXBContext.
>>>
>>> Please clarify.
>>>
>>> Thank you,
>>> Arul
>>>
>>>
>>>
>>>
>>
>> ---
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>>
>>
>>
>>
>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>
>
> ________________________________
> Scanned by MessageLabs for Flux
> ________________________________


Re: configuring custom JAXB annotation readers in CXF

Posted by Daniel Kulp <dk...@apache.org>.
I just realized this is covered in the docs:

http://cwiki.apache.org/CXF20DOC/jaxb.html


Dan



On Jun 23, 2008, at 9:22 PM, Daniel Kulp wrote:

>
> The JAXBDataBinding object has maps for both contextProperties and  
> marshallerProperties that can be configured via spring  
> configuration.   Unfortunately, it doesn't look like we have an  
> example of configuring via spring, just via the apis.  :-(
>
> Dan
>
>
>
> On Jun 23, 2008, at 4:45 PM, Arul Dhesiaseelan wrote:
>
>> Hi,
>>
>> One of my bean method returns IOException. When I start my web  
>> service, I get "java.lang.StackTraceElement does not have a no-arg  
>> default constructor".
>>
>> I see this issue could be overcome using JAXB introductions  
>> discussed in this thread: http://forums.java.net/jive/thread.jspa?messageID=282016 
>>  which allows to add XmlTransient annotations to  
>> java.lang.Exception class.
>>
>> How would I configure CXF to invoke these custom JAXB annotation  
>> readers during runtime? I am not sure as to how this custom  
>> JAXBContext could be created to override CXF JAXBContext.
>>
>> Please clarify.
>>
>> Thank you,
>> Arul
>>
>>
>>
>>
>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog





Re: configuring custom JAXB annotation readers in CXF

Posted by Daniel Kulp <dk...@apache.org>.
The JAXBDataBinding object has maps for both contextProperties and  
marshallerProperties that can be configured via spring  
configuration.   Unfortunately, it doesn't look like we have an  
example of configuring via spring, just via the apis.  :-(

Dan



On Jun 23, 2008, at 4:45 PM, Arul Dhesiaseelan wrote:

> Hi,
>
> One of my bean method returns IOException. When I start my web  
> service, I get "java.lang.StackTraceElement does not have a no-arg  
> default constructor".
>
> I see this issue could be overcome using JAXB introductions  
> discussed in this thread: http://forums.java.net/jive/thread.jspa?messageID=282016 
>  which allows to add XmlTransient annotations to java.lang.Exception  
> class.
>
> How would I configure CXF to invoke these custom JAXB annotation  
> readers during runtime? I am not sure as to how this custom  
> JAXBContext could be created to override CXF JAXBContext.
>
> Please clarify.
>
> Thank you,
> Arul
>
>
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog