-
CXF+spring+hibernate客户端调用总出错30
我用cxf做的webserver已经发布成功并能看到以下wsdl<?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions name="cxfWebServerImplService" targetNamespace="http://spingDao.com/" xmlns:ns1="http://spingdao.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://spingDao.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:import location="http://localhost:8899/hib3/cxfWebServer?wsdl=cxfWebServer.wsdl" namespace="http://spingdao.com/" /> - <wsdl:message name="getJobseekeruser"> <wsdl:part element="ns1:getJobseekeruser" name="parameters" /> </wsdl:message> - <wsdl:message name="insertDataResponse"> <wsdl:part element="ns1:insertDataResponse" name="parameters" /> </wsdl:message> - <wsdl:message name="getJobseekeruserResponse"> <wsdl:part element="ns1:getJobseekeruserResponse" name="parameters" /> </wsdl:message> - <wsdl:message name="insertData"> <wsdl:part element="ns1:insertData" name="parameters" /> </wsdl:message> - <wsdl:binding name="cxfWebServerImplServiceSoapBinding" type="ns1:cxfWebServer"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="getJobseekeruser"> <soap:operation soapAction="" style="document" /> - <wsdl:input name="getJobseekeruser"> <soap:body use="literal" /> </wsdl:input> - <wsdl:output name="getJobseekeruserResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> - <wsdl:operation name="insertData"> <soap:operation soapAction="" style="document" /> - <wsdl:input name="insertData"> <soap:body use="literal" /> </wsdl:input> - <wsdl:output name="insertDataResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> - <wsdl:service name="cxfWebServerImplService"> - <wsdl:port binding="tns:cxfWebServerImplServiceSoapBinding" name="cxfWebServerPort"> <soap:address location="http://localhost:8899/hib3/cxfWebServer" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
但是当我在客户端写以下调用时总出错:
客户端代码:public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "classpath:/com/webserver/clinet/client-beans.xml"}); cxfWebServer client = (cxfWebServer) context.getBean("client"); Jobseekeruser user=new Jobseekeruser(); user.setCheckstatus((long)1); user.setJobseekerid((long)1092); java.util.Date d=new java.util.Date(); user.setCreatedate(d); user.setEmail("21@job88.com"); user.setEmailstatus((long)1); user.setJobseekercode("JP00332d3"); user.setJobseekerlogin("trais"); user.setLastlogindate(d); user.setUpdatedate(d); user.setCheckstatus((long)1); user.setPassword("123w"); boolean response = client.insertData(user); System.out.println("Response: " + response); System.exit(0); }
错误:- Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
- at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
- at $Proxy42.insertData(Unknown Source)
- at com.webserver.clinet.jobseekerclient.main(jobseekerclient.java:44)
- Caused by: org.apache.cxf.binding.soap.SoapFault: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
- at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
- at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:1)
- at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
- at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
- at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:65)
- at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:1)
- at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
- at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:449)
- at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1996)
- at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1832)
- at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
- at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:591)
- at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
- at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
- at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
- at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
- at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
- at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
- ... 2 more
其他的服务端代码:@WebService(name="cxfWebServer", targetNamespace="http://spingdao.com/") public interface cxfWebServer { public boolean insertData(Jobseekeruser user); public Jobseekeruser getJobseekeruser(long id); }
@WebService(endpointInterface="com.spingDao.cxfWebServer",name="cxfWebServer") public class cxfWebServerImpl implements cxfWebServer { public Jobseekeruser getJobseekeruser(long id) { //ApplicationContext ap = new ClassPathXmlApplicationContext("applicationContext.xml"); JobseekeruserDAO jdo =new JobseekeruserDAO(); // TODO Auto-generated method stub return (Jobseekeruser) jdo.findAll().get(0); } public boolean insertData(Jobseekeruser user) { SaveJobseeker sav=new SaveJobseeker(); sav.insertJobseekerUser(user); return true; } }
*/ @XmlAccessorType() @XmlType(name = "User") public class Jobseekeruser implements java.io.Serializable { // Fields private Long jobseekerid; private String jobseekerlogin; private String jobseekercode; private String email; private String password; private Date createdate; private Date updatedate; private Date lastlogindate; private Long checkstatus; private Long emailstatus; // Constructors /** default constructor */ public Jobseekeruser() { } /** minimal constructor */ public Jobseekeruser(Long jobseekerid, String jobseekerlogin, String email) { this.jobseekerid = jobseekerid; this.jobseekerlogin = jobseekerlogin; this.email = email; } /** full constructor */ public Jobseekeruser(Long jobseekerid, String jobseekerlogin, String jobseekercode, String email, String password, Date createdate, Date updatedate, Date lastlogindate, Long checkstatus, Long emailstatus) { this.jobseekerid = jobseekerid; this.jobseekerlogin = jobseekerlogin; this.jobseekercode = jobseekercode; this.email = email; this.password = password; this.createdate = createdate; this.updatedate = updatedate; this.lastlogindate = lastlogindate; this.checkstatus = checkstatus; this.emailstatus = emailstatus; } // Property accessors public Long getJobseekerid() { return this.jobseekerid; } public void setJobseekerid(Long jobseekerid) { this.jobseekerid = jobseekerid; } public String getJobseekerlogin() { return this.jobseekerlogin; } public void setJobseekerlogin(String jobseekerlogin) { this.jobseekerlogin = jobseekerlogin; } public String getJobseekercode() { return this.jobseekercode; } public void setJobseekercode(String jobseekercode) { this.jobseekercode = jobseekercode; } public String getEmail() { return this.email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public Date getCreatedate() { return this.createdate; } public void setCreatedate(Date createdate) { this.createdate = createdate; } public Date getUpdatedate() { return this.updatedate; } public void setUpdatedate(Date updatedate) { this.updatedate = updatedate; } public Date getLastlogindate() { return this.lastlogindate; } public void setLastlogindate(Date lastlogindate) { this.lastlogindate = lastlogindate; } public Long getCheckstatus() { return this.checkstatus; } public void setCheckstatus(Long checkstatus) { this.checkstatus = checkstatus; } public Long getEmailstatus() { return this.emailstatus; } public void setEmailstatus(Long emailstatus) { this.emailstatus = emailstatus; } }
与数据库操作的代码:public class SaveJobseeker { public boolean insertJobseekerUser(Jobseekeruser user) { ClassPathXmlApplicationContext ap = new ClassPathXmlApplicationContext( "/applicationContext.xml"); JobseekeruserDAO jdo = (JobseekeruserDAO) ap.getBean("personDao"); //System.out.println("insert Start!"); try { jdo.save(user); } catch (Exception ex) { //System.out.println(ex.getLocalizedMessage()); return false; } //System.out.println("insert end!"); return true; } }
其他的是spring与hibernate生成的JobseekeruserDAO.java(略)
而在.net端调用时出现的错错误以下:
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
2008年7月30日 22:36
2个答案 按时间排序 按投票排序
-
采纳的答案
引用java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
是否少了jar包2008年7月31日 10:39
-
Could not initialize class net.sf.cglib.proxy.Enhancer
net.sf.cglib.proxy.Enhancer该类无法初始化
net.sf.cglib.proxy.Enhancer和MethodInterceptor在CGLib包中负责完成代理对象创建和方法截获处理
我想 你应该是这个包未导入造成的
可以去http://sourceforge.net/project/showfiles.php?group_id=56933下来看看2008年7月31日 10:54
相关推荐
简单的webservice+Cxf+Spring数据对接实例以及jar.rar简单的webservice+Cxf+Spring数据对接实例以及jar.rar简单的webservice+Cxf+Spring数据对接实例以及jar.rar简单的webservice+Cxf+Spring数据对接实例以及jar.rar...
cxf+spring+hibernate整合添加功能实现修改版是对完整版的修正,有兴趣的同学可以下载研究一下。
ibatis+spring+cxf+mysql搭建webservice的客户端,文章地址在http://blog.csdn.net/cenyi2013/article/details/17315755. 服务端源码的下载地址在http://download.csdn.net/detail/cenyi2012/6712729
CXF+Spring+Hibernate实现WebService,实现的方法比较简单,只有一个增加的方法,没有用到Struts 有服务端代码和客户端测试代码
cxf+spring+hibernate集成整合jar包
csh框架+cxf+spring+hibernate+mysql 注解 annotation xml json, 参考了菠萝大象的文章,感谢。
cxf+spring实现webservice
使用cxf+spring框架开发webservice的客户端与服务端代码,用于连接两个项目
cxf+spring实现webservice的客户端例子,在eclipse开发工具上已经测试通过,里面没有lib,如果有需要的话,可以给我留言,可以单发!
CXF+spring+struts实现WebService
使用idea创建maven项目组建spring+cxf 客户端使用idea创建java Enterprise 中的WebServices Client进行创建
cxf+spring+client+springmvc
Spring+CXF+MyBatis整合客户端代码
cxf+spring+tomcat 只是演示,一个helloWorld的例子
内容为CXF整合spring的服务端和客户端开发例子,注释不太详尽,网上的教程比较多,但是多跑不起来,特地把整个工程都打包给大家做参考,程序内容均来自网上整理,均可以运行。
CXF2.7+SPRING3.0.5+HIBERNATE3.6final+STRUTS2的所有jar包完全配好了,并已经成功项目中应用,使用者只需将文件解压拷到项目的lib文件夹下即可
cxf+spring整合,只要把项目导入到myeclipse中,就可以运行。
CXF+Spring+Tomcat发布WebService
代码是我一行行敲的,直接部署就能用,service,client端实现了:(cxf用的是3.0最新的) 1维数组, 2维数组, 3维数组, List, List , Map(adapter方式实现的), 直接返回bean, 返回object[], 做了header的安全认证校验.
这是我在使用cxf+spring进行开发中的一点总结,如何搭建开发环境、如何配置dao使用,如何解决乱码问题等的经验分享