有以下异常,求大家帮忙解决一下:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.Sets.newIdentityHashSet()Ljava/util/Set;
at org.glassfish.jersey.model.internal.CommonConfig.<init>(CommonConfig.java:215)
at org.glassfish.jersey.client.ClientConfig$State.<init>(ClientConfig.java:144)
at org.glassfish.jersey.client.ClientConfig.<init>(ClientConfig.java:423)
at org.glassfish.jersey.client.JerseyClientBuilder.<init>(JerseyClientBuilder.java:72)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at javax.ws.rs.client.FactoryFinder.newInstance(FactoryFinder.java:116)
at javax.ws.rs.client.FactoryFinder.find(FactoryFinder.java:206)
at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:86)
at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)
at renlai.client.pc.service.MenberBase.MenberBaseService.menberLogin(MenberBaseService.java:25)
at renlai.client.pc.service.MenberBase.MenberBaseService.main(MenberBaseService.java:47)
1、调用方法处:Client客户端,这是编写了一个main方法测试的时候出错了
public class MenberBaseService {
//生成客户端对象
Client client=ClientBuilder.newClient();
//定义路径
String strUrl="http://localhost:6060/GRZYService/services";
//获取当前对象的webTarget
WebTarget target=client.target(strUrl);
//获取对应的webService类
WebTarget resouce=target.path("MenberBaseService");
//获得对应的webService方法
WebTarget menberLogin=resouce.path("menberLogin/"+"1000006973");
//响应类型
Invocation.Builder builder=menberLogin.request(MediaType.APPLICATION_JSON);
public MenberBase menberLogin(){
MenberBase menberBase=null;
//获取响应对象
Response response=builder.get();
System.out.println(response.getStatus());
//获取响应内容
//String menberResult=response.readEntity(String.class);
System.out.println();
return menberBase;
}
public static void main(String[] args) {
MenberBaseService mbs=new MenberBaseService();
MenberBase mb=mbs.menberLogin();
System.out.println(mb.getMbEmail());
}
2、被调用的方法处:webserivce
/**
* @author Cavion
* 2013-12-24
*/
@Path("MenberBaseService")
public class MenberBaseService {
/**
* 根据id查询,用于登陆
* @param mid
* @return
*/
@GET
@Path("menberLogin/{mid}")
@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public MenberBase findByid(@PathParam("mid") String mid){
String hql="from MenberBase mb where mb.mbId=?";
MenberBase menberBase=(MenberBase) HibernateBase.findById(hql, mid);
return menberBase;
}
3、webservice的实体类:引用的是hibernate
package renlai.cavion.grzy.hibernate.domain.Menber;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
/**
* MenberBase entity. @author MyEclipse Persistence Tools
*/
@XmlRootElement
public class MenberBase implements java.io.Serializable {
// Fields
/**
*
*/
private static final long serialVersionUID = -1347079687110430853L;
private String mbId;
private MenberNation menberNation;
private String mbPwd;
private String mbName;
private String mbNickName;
private Integer mbSexy;
private Timestamp mbBorn;
private String mbPhone;
private String mbQq;
private String mbPwdEmail;
private String mbEmail;
private String mbImagePath;
//private Set menberAddresses = new HashSet(0);
// Constructors
/** default constructor */
public MenberBase() {
}
/** minimal constructor */
public MenberBase(MenberNation menberNation, String mbPwd,
String mbNickName, Integer mbSexy, String mbEmail) {
this.menberNation = menberNation;
this.mbPwd = mbPwd;
this.mbNickName = mbNickName;
this.mbSexy = mbSexy;
this.mbEmail = mbEmail;
}
/** full constructor */
public MenberBase(MenberNation menberNation, String mbPwd, String mbName,
String mbNickName, Integer mbSexy, Timestamp mbBorn,
String mbPhone, String mbQq, String mbPwdEmail, String mbEmail,
String mbImagePath, Set menberAddresses) {
this.menberNation = menberNation;
this.mbPwd = mbPwd;