求高人帮忙解决异常
Exception in thread "main"
java.lang.NoSuchMethodError:
有以下异常,求大家帮忙解决一下:
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的实体类: