iteye_915 2011-11-24 23:03
浏览 278
已采纳

cxf spring集合中开发Web Service遇见的java.util.Date无缺省函数问题

cxf spring集合中开发Web Service遇见的java.util.Date无缺省函数问题 

在domain中有User类

public class User {

 

         private String userName;

private String userPassword;

private String mobile;

private String email;

private String nickname;

private String region;

private java.sql.Date birthday ;

private String telephone;

private String address;

private String postcode;

private String signature;

private String imageUrl;

private int userID;

} 其中birthday类型为java.sql.Date,没有开发web service时,使用spring 和hibernate都OK 加入cxf后报错了 

 

 

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserWebService1111': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)

at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)

at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:662)

Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException

at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)

at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)

at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)

... 20 more

Caused by: org.apache.cxf.service.factory.ServiceConstructionException

at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:292)

at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)

at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:444)

at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)

at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:507)

at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)

at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)

at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)

at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:157)

at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)

at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)

at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)

... 29 more

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions

java.sql.Date does not have a no-arg default constructor.

this problem is related to the following location:

at java.sql.Date

at public java.sql.Date com.tianxiao.whut.domain.User.getBirthday()

at com.tianxiao.whut.domain.User

at private java.util.List com.tianxiao.whut.webservice.jaxws_asm.QueryByNicknameResponse._return

at com.tianxiao.whut.webservice.jaxws_asm.QueryByNicknameResponse

 

at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)

at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466)

at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)

at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)

at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1157)

at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)

at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)

at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)

at org.apache.cxf.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:260)

at org.apache.cxf.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:169)

at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:418)

at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:290)

... 40 more

 

请问这个该如何解决?

 

  • 写回答

4条回答 默认 最新

  • 爱上一条鱼 2011-11-25 08:33
    关注

    [quote]java.sql.Date does not have a no-arg default constructor.[/quote]
    也就是说java.sql.Date这个类是不能这样创建实例的
    [code="java"]java.sql.Date date = new java.sql.Date();[/code]

    要用
    [code="java"]java.sql.Date date = new java.sql.Date(new java.util.Date().getTime() );[/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏