trainli 2008-07-30 22:36 采纳率: 0%
浏览 232
已采纳

CXF+spring+hibernate客户端调用总出错

我用cxf做的webserver已经发布成功并能看到以下wsdl
[code="java"]
<?xml version="1.0" encoding="UTF-8" ?>

但是当我在客户端写以下调用时总出错:
客户端代码:
[code="java"]
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);
}[/code]

错误:
[list=1]
[*]
[*]

[*]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
[/list]

其他的服务端代码:
[code="java"]
@WebService(name="cxfWebServer", targetNamespace="http://spingdao.com/")
public interface cxfWebServer {

public boolean insertData(Jobseekeruser user);
public Jobseekeruser  getJobseekeruser(long id);

}[/code]

[code="java"]
@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;
}

}[/code]

[code="java"]*/
@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;
}

}[/code]

与数据库操作的代码:
[code="java"]
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;
}
}[/code]

其他的是spring与hibernate生成的JobseekeruserDAO.java(略)

而在.net端调用时出现的错错误以下:

[list]
[*]
[*] 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
[/list]

  • 写回答

2条回答 默认 最新

  • lggegegmail 2008-07-31 10:39
    关注

    [quote]java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer[/quote]

    是否少了jar包

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

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置