我正在sortedset.com(Apache CXF,TomEE)尝试JAX-WS示例,我修改它以包含一个复杂的对象。我在NullPointerException
获得org.apache.cxf.jaxb.Utils.getMethodXJTA(Utils.java:294)
。我的代码中是否有任何缺失的注释?或者还有更多的工作来编组复杂的物体?
import javax.jws.WebService;
@WebService(
portName = "HelloTomEEPort",
serviceName = "HelloTomEEService",
targetNamespace = "http://sortedset.com/wsdl",
endpointInterface = "HelloTomEEWs")
public class HelloTomEEIMplementation implements HelloTomEEWs {
public Person getPerson(){
Person p = new Person();
p.setID(5);
p.setName("Tom");
return p;
}
}
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://sortedset.com/wsdl")
public interface HelloTomEEWs {
@WebMethod
public Person getPerson();
}
import javax.xml.bind.annotation.XmlRegistry;
@XmlRegistry
public class Person{
/**
*
*/
private int iD;
private String name;
public int getID() {
return iD;
}
public void setID(int iD) {
this.iD = iD;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
严重:在为servlet部署CXF Web服务时出错 HelloTomEEIMplementation java.lang.NullPointerException at org.apache.cxf.jaxb.Utils.getMethodXJTA(Utils.java:294)at at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:375) 在 org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:329) 在 org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:232) 在 org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:222) 在 org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:365) 在 org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:329) 在 org.apache.cxf.jaxb.JAXBContextInitializer.begin(JAXBContextInitializer.java:183) 在 org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceModelVisitor.java:109) 在 org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.java:74) 在 org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:325) 在 org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) 在 org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:490) 在 org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:697) 在 org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550) 在 org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265) 在 org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:214) 在 org.apache.openejb.server.cxf.CxfEndpoint.doServiceCreate(CxfEndpoint.java:101) 在 org.apache.openejb.server.cxf.pojo.PojoEndpoint。(PojoEndpoint.java:67) 在 org.apache.openejb.server.cxf.pojo.PojoWsContainer.createEndpoint(PojoWsContainer.java:70) 在 org.apache.openejb.server.cxf.pojo.PojoWsContainer.createEndpoint(PojoWsContainer.java:45) 在 org.apache.openejb.server.cxf.CxfWsContainer.start(CxfWsContainer.java:50) 在 org.apache.openejb.server.cxf.CxfService.createPojoWsContainer(CxfService.java:102) 在 org.apache.openejb.server.webservices.WsService.afterApplicationCreated(WsService.java:390) 在 org.apache.tomee.webservices.TomeeJaxWsService.afterApplicationCreated(TomeeJaxWsService.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at java.lang.reflect.Method.invoke(未知来源)at org.apache.openejb.observer.ObserverManager $ Observer.invoke(ObserverManager.java:149) 在 org.apache.openejb.observer.ObserverManager.fireEvent(ObserverManager.java:69) 在 org.apache.openejb.loader.SystemInstance.fireEvent(SystemInstance.java:108) 在 org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:1608) 在 org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:113) 在 org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) 在 org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 在 org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168) 在 org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1559) 在 org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549) 在java.util.concurrent.FutureTask.run(未知来源)at java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)at java.lang.Thread.run(未知来源)
答案 0 :(得分:0)
尝试使用@XmlType
代替@XmlRegistry