gpt4 book ai didi

java - JAX-WS复杂对象

转载 作者:行者123 更新时间:2023-12-02 01:32:11 26 4
gpt4 key购买 nike

我正在尝试位于 sortedset.com 的 JAX-WS 示例(Apache CXF、TomEE)我修改了它以包含一个复杂的对象。我在 org.apache.cxf.jaxb.Utils.getMethodXJTA(Utils.java:294) 处收到 NullPointerException。我的代码中是否缺少注释?或者还需要做更多的事情来整理复杂的对象吗?

 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;
}

}

SEVERE: Error deploying CXF webservice for servlet HelloTomEEIMplementation java.lang.NullPointerException at org.apache.cxf.jaxb.Utils.getMethodXJTA(Utils.java:294) at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:375) at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:329) at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:232) at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:222) at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:365) at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:329) at org.apache.cxf.jaxb.JAXBContextInitializer.begin(JAXBContextInitializer.java:183) at org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceModelVisitor.java:109) at org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.java:74) at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:325) at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:490) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:697) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:214) at org.apache.openejb.server.cxf.CxfEndpoint.doServiceCreate(CxfEndpoint.java:101) at org.apache.openejb.server.cxf.pojo.PojoEndpoint.(PojoEndpoint.java:67) at org.apache.openejb.server.cxf.pojo.PojoWsContainer.createEndpoint(PojoWsContainer.java:70) at org.apache.openejb.server.cxf.pojo.PojoWsContainer.createEndpoint(PojoWsContainer.java:45) at org.apache.openejb.server.cxf.CxfWsContainer.start(CxfWsContainer.java:50) at org.apache.openejb.server.cxf.CxfService.createPojoWsContainer(CxfService.java:102) at org.apache.openejb.server.webservices.WsService.afterApplicationCreated(WsService.java:390) at org.apache.tomee.webservices.TomeeJaxWsService.afterApplicationCreated(TomeeJaxWsService.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.openejb.observer.ObserverManager$Observer.invoke(ObserverManager.java:149) at org.apache.openejb.observer.ObserverManager.fireEvent(ObserverManager.java:69) at org.apache.openejb.loader.SystemInstance.fireEvent(SystemInstance.java:108) at org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:1608) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:113) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

最佳答案

尝试使用@XmlType而不是@XmlRegistry

关于java - JAX-WS复杂对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25093088/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com