You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Luca Ceppelli <ce...@yahoo.com> on 2007/06/27 14:27:20 UTC

Marshalling Error: class bug.Result nor any of its super class is known to this context.


Hi all.


 


I’m trying to develop a cxf servant with the ServerFactoryBean
but when I try to invoke an operation, which returns an custom type, I receive
the following exception:


 


27-Jun-2007 14:13:05
org.apache.cxf.phase.PhaseInterceptorChain doIntercept


INFO: Interceptor has thrown exception, unwinding now


org.apache.cxf.interceptor.Fault: Marshalling Error: class
bug.Result nor any of its super class is known to this context.


                at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:134)


                at
org.apache.cxf.jaxb.io.XMLStreamDataWriter.write(XMLStreamDataWriter.java:42)


                at
org.apache.cxf.jaxb.io.XMLStreamDataWriter.write(XMLStreamDataWriter.java:30)


                at
org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:73)


                at
org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptor.handleMessage(XMLMessageOutInterceptor.java:69)


                at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:148)


                at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:70)


                at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:148)


                at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:63)


                at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:200)


                at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:161)


                at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:54)


                at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)


                at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)


                at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)


                at
org.mortbay.jetty.Server.handle(Server.java:295)


                at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:503)


                at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:841)


                at
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:639)


                at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:210)


                at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:379)


                at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:361)


                at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)


Caused by: javax.xml.bind.JAXBException: class bug.Result
nor any of its super class is known to this context.


                at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:507)


                at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:449)


                at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292)


                at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:148)


                at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:123)


                ... 22
more


 


 


Any suggestion?


 


Thanks,


Luca.






My environment is:


 


WindowsXp SP2


JDK 1.5.0_06


CXF-2.0-incubator-RC

 


Following you could find the code of my testcase:


 


package bug;


 


public interface Bug {


 


                Result
bug1();


 


}


 


package bug;


 


public class BugImpl implements Bug {


 


                public
Result bug1() {


                                return new Result(true, "Bug
1 Response!");


                }


}


 


 


public class Result {


                


                private
boolean fault;


                


                private
String message;


                


                public
Result(boolean fault, String message) {


                                this.fault = fault;


                                this.message = message;


                }


 


                public boolean
isFault() {


                                return fault;


                }


 


                public void
setFault(boolean fault) {


                                this.fault = fault;


                }


 


                public
String getMessage() {


                                return message;


                }


 


                public void
setMessage(String message) {


                                this.message = message;


                }


 


}


 


package bug;


 


import org.apache.cxf.endpoint.Server;


import org.apache.cxf.frontend.ServerFactoryBean;


 


public class MainBug {




 


                public
static void main(String[] args) {


                                ServerFactoryBean svrFactory =
new ServerFactoryBean();


 


                                svrFactory.setServiceClass(Bug.class);


 


                                svrFactory.setServiceBean(new
BugImpl());


 


                                svrFactory.setBindingId("http://cxf.apache.org/bindings/xformat");


                                svrFactory.setTransportId("http://schemas.xmlsoap.org/wsdl/http/");


 


                                svrFactory.setAddress("http://localhost:8080/bug");


 


                                Server server =
svrFactory.create();


 


                }


 


}








	
		
___________________________________ 
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: 
http://it.docs.yahoo.com/nowyoucan.html

Re: Marshalling Error: class bug.Result nor any of its super class is known to this context.

Posted by Dan Diephouse <da...@envoisolutions.com>.
BTW, I just made a few improvements to the Aegis Databinding docs, you can
see them here (it will take a few hours for them to get sync'd to the main
website):

http://cwiki.apache.org/confluence/display/CXF20DOC/Aegis+Databinding

- Dan

On 6/27/07, Dan Diephouse <da...@envoisolutions.com> wrote:
>
> A couple thoughts:
>
> 1. CXF uses JAXB as the default databinding. Because of this you need to
> ensure that you've annotated your domain objects with @XmlType or
> @XmlRootElement. I think you also need to create a " jaxb.index" file in
> the same package as Result with just a single line that says "Result". This
> is basically a list of classes JAXB should pick up.
>
> 2. Result may need a default constructor. It will definitely need one if
> you're using the same Result class on the client side.
>
> 3. You may want to look into using the Aegis databinding which doesn't
> require any annotations/index files at all. http://cwiki.apache.org/CXF20DOC/aegis-databinding.html
>
>
> Regards,
> - Dan
>
> P.S. your email was formatted really weird - there were several empty
> lines in between each written line. You might want to look into that. :-)
>
>
> On 6/27/07, Luca Ceppelli <ce...@yahoo.com> wrote:
> >
> >
> >
> > Hi all.
> >
> >
> >
> >
> >
> > I'm trying to develop a cxf servant with the ServerFactoryBean
> > but when I try to invoke an operation, which returns an custom type, I
> > receive
> > the following exception:
> >
> >
> >
> >
> >
> > 27-Jun-2007 14:13:05
> > org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> >
> >
> > INFO: Interceptor has thrown exception, unwinding now
> >
> >
> > org.apache.cxf.interceptor.Fault: Marshalling Error: class
> > bug.Result nor any of its super class is known to this context.
> >
> >
> >                 at
> > org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java
> > :134)
> >
> >
> >                 at
> > org.apache.cxf.jaxb.io.XMLStreamDataWriter.write (
> > XMLStreamDataWriter.java:42)
> >
> >
> >                 at
> > org.apache.cxf.jaxb.io.XMLStreamDataWriter.write(
> > XMLStreamDataWriter.java:30)
> >
> >
> >                 at
> > org.apache.cxf.interceptor.BareOutInterceptor.handleMessage (
> > BareOutInterceptor.java:73)
> >
> >
> >                 at
> >
> > org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptor.handleMessage
> > (XMLMessageOutInterceptor.java:69)
> >
> >
> >                 at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > PhaseInterceptorChain.java:148)
> >
> >
> >                 at
> > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(
> > OutgoingChainInterceptor.java:70)
> >
> >
> >                 at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > PhaseInterceptorChain.java:148)
> >
> >
> >                 at
> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(
> > ChainInitiationObserver.java:63)
> >
> >
> >                 at
> > org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(
> > JettyHTTPDestination.java:200)
> >
> >
> >                 at
> > org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(
> > JettyHTTPDestination.java:161)
> >
> >
> >                 at
> > org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle (
> > JettyHTTPHandler.java:54)
> >
> >
> >                 at
> > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
> >
> >
> >                 at
> > org.mortbay.jetty.handler.ContextHandlerCollection.handle (
> > ContextHandlerCollection.java:211)
> >
> >
> >                 at
> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
> >
> >
> >                 at
> > org.mortbay.jetty.Server.handle(Server.java:295)
> >
> >
> >                 at
> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:503)
> >
> >
> >                 at
> > org.mortbay.jetty.HttpConnection$RequestHandler.content(
> > HttpConnection.java:841)
> >
> >
> >                 at
> > org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:639)
> >
> >
> >                 at
> > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:210)
> >
> >
> >                 at
> > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:379)
> >
> >
> >                 at
> > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java
> > :361)
> >
> >
> >                 at
> > org.mortbay.thread.BoundedThreadPool$PoolThread.run (
> > BoundedThreadPool.java:442)
> >
> >
> > Caused by: javax.xml.bind.JAXBException: class bug.Result
> > nor any of its super class is known to this context.
> >
> >
> >                 at
> > com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo (
> > JAXBContextImpl.java:507)
> >
> >
> >                 at
> > com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java
> > :449)
> >
> >
> >                 at
> > com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292)
> >
> >
> >                 at
> > com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java
> > :148)
> >
> >
> >                 at
> > org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:123)
> >
> >
> >
> >                 ... 22
> > more
> >
> >
> >
> >
> >
> >
> >
> >
> > Any suggestion?
> >
> >
> >
> >
> >
> > Thanks,
> >
> >
> > Luca.
> >
> >
> >
> >
> >
> >
> > My environment is:
> >
> >
> >
> >
> >
> > WindowsXp SP2
> >
> >
> > JDK 1.5.0_06
> >
> >
> > CXF-2.0-incubator-RC
> >
> >
> >
> >
> > Following you could find the code of my testcase:
> >
> >
> >
> >
> >
> > package bug;
> >
> >
> >
> >
> >
> > public interface Bug {
> >
> >
> >
> >
> >
> >                 Result
> > bug1();
> >
> >
> >
> >
> >
> > }
> >
> >
> >
> >
> >
> > package bug;
> >
> >
> >
> >
> >
> > public class BugImpl implements Bug {
> >
> >
> >
> >
> >
> >                 public
> > Result bug1() {
> >
> >
> >                                 return new Result(true, "Bug
> > 1 Response!");
> >
> >
> >                 }
> >
> >
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> > public class Result {
> >
> >
> >
> >
> >
> >                 private
> > boolean fault;
> >
> >
> >
> >
> >
> >                 private
> > String message;
> >
> >
> >
> >
> >
> >                 public
> > Result(boolean fault, String message) {
> >
> >
> >                                  this.fault = fault;
> >
> >
> >                                 this.message = message;
> >
> >
> >                 }
> >
> >
> >
> >
> >
> >                 public boolean
> > isFault() {
> >
> >
> >                                 return fault;
> >
> >
> >                 }
> >
> >
> >
> >
> >
> >                 public void
> > setFault(boolean fault) {
> >
> >
> >                                 this.fault = fault;
> >
> >
> >                 }
> >
> >
> >
> >
> >
> >                 public
> > String getMessage() {
> >
> >
> >                                 return message;
> >
> >
> >                 }
> >
> >
> >
> >
> >
> >                 public void
> > setMessage(String message) {
> >
> >
> >                                 this.message = message;
> >
> >
> >                 }
> >
> >
> >
> >
> >
> > }
> >
> >
> >
> >
> >
> > package bug;
> >
> >
> >
> >
> >
> > import org.apache.cxf.endpoint.Server;
> >
> >
> > import org.apache.cxf.frontend.ServerFactoryBean;
> >
> >
> >
> >
> >
> > public class MainBug {
> >
> >
> >
> >
> >
> >
> >
> >                 public
> > static void main(String[] args) {
> >
> >
> >                                 ServerFactoryBean svrFactory =
> > new ServerFactoryBean();
> >
> >
> >
> >
> >
> >                                 svrFactory.setServiceClass(Bug.class);
> >
> >
> >
> >
> >
> >                                 svrFactory.setServiceBean(new
> > BugImpl());
> >
> >
> >
> >
> >
> >                                 svrFactory.setBindingId("
> > http://cxf.apache.org/bindings/xformat");
> >
> >
> >                                  svrFactory.setTransportId("
> > http://schemas.xmlsoap.org/wsdl/http/");
> >
> >
> >
> >
> >
> >                                 svrFactory.setAddress("http://localhost:8080/bug
> > ");
> >
> >
> >
> >
> >
> >                                 Server server =
> > svrFactory.create();
> >
> >
> >
> >
> >
> >                 }
> >
> >
> >
> >
> >
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ___________________________________
> > L'email della prossima generazione? Puoi averla con la nuova Yahoo!
> > Mail:
> > http://it.docs.yahoo.com/nowyoucan.html
> >
>
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog




-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: Marshalling Error: class bug.Result nor any of its super class is known to this context.

Posted by Dan Diephouse <da...@envoisolutions.com>.
A couple thoughts:

1. CXF uses JAXB as the default databinding. Because of this you need to
ensure that you've annotated your domain objects with @XmlType or
@XmlRootElement. I think you also need to create a "jaxb.index" file in the
same package as Result with just a single line that says "Result". This is
basically a list of classes JAXB should pick up.

2. Result may need a default constructor. It will definitely need one if
you're using the same Result class on the client side.

3. You may want to look into using the Aegis databinding which doesn't
require any annotations/index files at all.
http://cwiki.apache.org/CXF20DOC/aegis-databinding.html

Regards,
- Dan

P.S. your email was formatted really weird - there were several empty lines
in between each written line. You might want to look into that. :-)


On 6/27/07, Luca Ceppelli <ce...@yahoo.com> wrote:
>
>
>
> Hi all.
>
>
>
>
>
> I'm trying to develop a cxf servant with the ServerFactoryBean
> but when I try to invoke an operation, which returns an custom type, I
> receive
> the following exception:
>
>
>
>
>
> 27-Jun-2007 14:13:05
> org.apache.cxf.phase.PhaseInterceptorChain doIntercept
>
>
> INFO: Interceptor has thrown exception, unwinding now
>
>
> org.apache.cxf.interceptor.Fault: Marshalling Error: class
> bug.Result nor any of its super class is known to this context.
>
>
>                 at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java
> :134)
>
>
>                 at
> org.apache.cxf.jaxb.io.XMLStreamDataWriter.write(XMLStreamDataWriter.java
> :42)
>
>
>                 at
> org.apache.cxf.jaxb.io.XMLStreamDataWriter.write(XMLStreamDataWriter.java
> :30)
>
>
>                 at
> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(
> BareOutInterceptor.java:73)
>
>
>                 at
>
> org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptor.handleMessage
> (XMLMessageOutInterceptor.java:69)
>
>
>                 at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:148)
>
>
>                 at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(
> OutgoingChainInterceptor.java:70)
>
>
>                 at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:148)
>
>
>                 at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(
> ChainInitiationObserver.java:63)
>
>
>                 at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(
> JettyHTTPDestination.java:200)
>
>
>                 at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(
> JettyHTTPDestination.java:161)
>
>
>                 at
> org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(
> JettyHTTPHandler.java:54)
>
>
>                 at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>
>
>                 at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(
> ContextHandlerCollection.java:211)
>
>
>                 at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>
>
>                 at
> org.mortbay.jetty.Server.handle(Server.java:295)
>
>
>                 at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:503)
>
>
>                 at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(
> HttpConnection.java:841)
>
>
>                 at
> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:639)
>
>
>                 at
> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:210)
>
>
>                 at
> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:379)
>
>
>                 at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java
> :361)
>
>
>                 at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java
> :442)
>
>
> Caused by: javax.xml.bind.JAXBException: class bug.Result
> nor any of its super class is known to this context.
>
>
>                 at
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(
> JAXBContextImpl.java:507)
>
>
>                 at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java
> :449)
>
>
>                 at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292)
>
>
>                 at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java
> :148)
>
>
>                 at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java
> :123)
>
>
>                 ... 22
> more
>
>
>
>
>
>
>
>
> Any suggestion?
>
>
>
>
>
> Thanks,
>
>
> Luca.
>
>
>
>
>
>
> My environment is:
>
>
>
>
>
> WindowsXp SP2
>
>
> JDK 1.5.0_06
>
>
> CXF-2.0-incubator-RC
>
>
>
>
> Following you could find the code of my testcase:
>
>
>
>
>
> package bug;
>
>
>
>
>
> public interface Bug {
>
>
>
>
>
>                 Result
> bug1();
>
>
>
>
>
> }
>
>
>
>
>
> package bug;
>
>
>
>
>
> public class BugImpl implements Bug {
>
>
>
>
>
>                 public
> Result bug1() {
>
>
>                                 return new Result(true, "Bug
> 1 Response!");
>
>
>                 }
>
>
> }
>
>
>
>
>
>
>
>
> public class Result {
>
>
>
>
>
>                 private
> boolean fault;
>
>
>
>
>
>                 private
> String message;
>
>
>
>
>
>                 public
> Result(boolean fault, String message) {
>
>
>                                 this.fault = fault;
>
>
>                                 this.message = message;
>
>
>                 }
>
>
>
>
>
>                 public boolean
> isFault() {
>
>
>                                 return fault;
>
>
>                 }
>
>
>
>
>
>                 public void
> setFault(boolean fault) {
>
>
>                                 this.fault = fault;
>
>
>                 }
>
>
>
>
>
>                 public
> String getMessage() {
>
>
>                                 return message;
>
>
>                 }
>
>
>
>
>
>                 public void
> setMessage(String message) {
>
>
>                                 this.message = message;
>
>
>                 }
>
>
>
>
>
> }
>
>
>
>
>
> package bug;
>
>
>
>
>
> import org.apache.cxf.endpoint.Server;
>
>
> import org.apache.cxf.frontend.ServerFactoryBean;
>
>
>
>
>
> public class MainBug {
>
>
>
>
>
>
>
>                 public
> static void main(String[] args) {
>
>
>                                 ServerFactoryBean svrFactory =
> new ServerFactoryBean();
>
>
>
>
>
>                                 svrFactory.setServiceClass(Bug.class);
>
>
>
>
>
>                                 svrFactory.setServiceBean(new
> BugImpl());
>
>
>
>
>
>                                 svrFactory.setBindingId("
> http://cxf.apache.org/bindings/xformat");
>
>
>                                 svrFactory.setTransportId("
> http://schemas.xmlsoap.org/wsdl/http/");
>
>
>
>
>
>                                 svrFactory.setAddress("
> http://localhost:8080/bug");
>
>
>
>
>
>                                 Server server =
> svrFactory.create();
>
>
>
>
>
>                 }
>
>
>
>
>
> }
>
>
>
>
>
>
>
>
>
>
> ___________________________________
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail:
> http://it.docs.yahoo.com/nowyoucan.html
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog