You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Roberto Druetto <ro...@gmail.com> on 2007/10/19 11:57:42 UTC

Problem with JAXB

Hi,
 I've a problem when I try to set up a service that return a n interface.
If I make a method that returns an object of mine, I have no problem
(the client get the object with no problems), instead if I make a
method that returns an interface I get this exception on server-side:
javax.xml.bind.JAXBException: it.ipsaweb.servermonitor.interfaces.Test

Here the methods:

MyObject getMyObject(); // ok, no problem
MyInterface getMyInterface(); // throws that exception

MyObject getMyObject(){
 return new MyObject();
}

MyInterface getMyInterface(){
  MyInterface m = new MyObject();
  return m;
}

what is the problem in your opinion?

Thanks.
Roberto

RE: Problem with JAXB

Posted by Benson Margulies <bi...@basistech.com>.
Or make a bean that can be constructed over your interface by slurping
up all the properties.

> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Friday, October 19, 2007 12:18 PM
> To: cxf-user@incubator.apache.org
> Cc: Roberto Druetto
> Subject: Re: Problem with JAXB
> 
> 
> Usually, you would create a abstract superclass and return that.
> 
> That said, there are some ways to do it.   See:
> https://jaxb.dev.java.net/guide/Mapping_interfaces.html
> 
> Dan
> 
> 
> On Friday 19 October 2007, Roberto Druetto wrote:
> > Thanks Jim,
> >  do you know how can I do the same thing? My intention is to
"monitor"
> > some devices (some methods that I can call from a client). The
devices
> > are different, so I don't have only one class...
> >
> > 2007/10/19, Jim Ma <em...@iona.com>:
> > > Hi ,
> > >
> > > If the method returns an interface , jaxb can not handle it and
> > > throws  exception .
> > > This is the reason why it can not :
> > >
http://weblogs.java.net/blog/kohsuke/archive/2006/06/jaxb_and_interf
> > >.html, FYI.
> > >
> > > Cheers
> > >
> > > Jim
> 
> 
> 
> --
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog

Re: Problem with JAXB

Posted by Daniel Kulp <dk...@apache.org>.
Usually, you would create a abstract superclass and return that. 

That said, there are some ways to do it.   See:
https://jaxb.dev.java.net/guide/Mapping_interfaces.html

Dan


On Friday 19 October 2007, Roberto Druetto wrote:
> Thanks Jim,
>  do you know how can I do the same thing? My intention is to "monitor"
> some devices (some methods that I can call from a client). The devices
> are different, so I don't have only one class...
>
> 2007/10/19, Jim Ma <em...@iona.com>:
> > Hi ,
> >
> > If the method returns an interface , jaxb can not handle it and
> > throws  exception .
> > This is the reason why it can not :
> > http://weblogs.java.net/blog/kohsuke/archive/2006/06/jaxb_and_interf
> >.html, FYI.
> >
> > Cheers
> >
> > Jim



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: Problem with JAXB

Posted by Roberto Druetto <ro...@gmail.com>.
Thanks Jim,
 do you know how can I do the same thing? My intention is to "monitor"
some devices (some methods that I can call from a client). The devices
are different, so I don't have only one class...

2007/10/19, Jim Ma <em...@iona.com>:
> Hi ,
>
> If the method returns an interface , jaxb can not handle it and
> throws  exception .
> This is the reason why it can not :
> http://weblogs.java.net/blog/kohsuke/archive/2006/06/jaxb_and_interf.html,
> FYI.
>
> Cheers
>
> Jim

Re: Problem with JAXB

Posted by Jim Ma <em...@iona.com>.
Hi ,

If the method returns an interface , jaxb can not handle it and
throws  exception .
This is the reason why it can not : 
http://weblogs.java.net/blog/kohsuke/archive/2006/06/jaxb_and_interf.html, 
FYI.

Cheers

Jim


Roberto Druetto wrote:
> Hi,
>  I've a problem when I try to set up a service that return a n interface.
> If I make a method that returns an object of mine, I have no problem
> (the client get the object with no problems), instead if I make a
> method that returns an interface I get this exception on server-side:
> javax.xml.bind.JAXBException: it.ipsaweb.servermonitor.interfaces.Test
>
> Here the methods:
>
> MyObject getMyObject(); // ok, no problem
> MyInterface getMyInterface(); // throws that exception
>
> MyObject getMyObject(){
>  return new MyObject();
> }
>
> MyInterface getMyInterface(){
>   MyInterface m = new MyObject();
>   return m;
> }
>
> what is the problem in your opinion?
>
> Thanks.
> Roberto
>
>