0 0

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


错误:
  1.   
  2. 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
  3. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
  4. at $Proxy42.insertData(Unknown Source)
  5. at com.webserver.clinet.jobseekerclient.main(jobseekerclient.java:44)
  6. 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
  7. at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
  8. at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:1)
  9. at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
  10. at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
  11. at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:65)
  12. at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:1)
  13. at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
  14. at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:449)
  15. at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1996)
  16. at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1832)
  17. at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
  18. at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:591)
  19. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
  20. at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
  21. at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
  22. at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
  23. at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
  24. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
  25. ... 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
SOA 
2008年7月30日 22:36

2个答案 按时间排序 按投票排序

0 0

采纳的答案

引用
java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer


是否少了jar包

2008年7月31日 10:39
0 0

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

相关推荐

Global site tag (gtag.js) - Google Analytics