当前位置: 首页 > 知识库问答 >
问题:

GenericType jersey客户端中的java.util.list.()

吕骞尧
2023-03-14

我正在使用泽西restful应用程序

def itemList= clientResponse.getEntity(new GenericType<List<Item>>(){});
Error |
java.lang.NoSuchMethodException: java.util.List.<init>()
Error |
    at java.lang.Class.getConstructor0(Class.java:3074)
Error |
    at java.lang.Class.getDeclaredConstructor(Class.java:2170)
Error |
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassGetDeclaredConstructor(ReflectiveInterceptor.java:456)
Error |
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassNewInstance(ReflectiveInterceptor.java:983)
Error |
    at com.sun.jersey.core.provider.jaxb.AbstractListElementProvider.readFrom(AbstractListElementProvider.java:306)
Error |
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:634)
Error |
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:604)
Error |
    at com.sun.jersey.api.client.ClientResponse$getEntity.call(Unknown Source)

谁能告诉我为什么它会来,什么是避免它的决心?

共有1个答案

何玺
2023-03-14

看起来Jersey试图通过反射实例化接口(List),但由于找不到构造函数而失败。

泽西岛的代码应该是

new GenericType<ArrayList<Item>>()
 类似资料:
  • 我想在一些计算机之间建立点对点连接,这样用户就可以在没有外部服务器的情况下聊天和交换文件。我最初的想法如下: 我在服务器上制作了一个中央服务器插座,所有应用程序都可以连接到该插座。此ServerSocket跟踪已连接的套接字(客户端),并将新连接的客户端的IP和端口提供给所有其他客户端。每个客户端都会创建一个新的ServerSocket,所有客户端都可以连接到它。 换句话说:每个客户端都有一个Se

  • 我使用生成的app engine Android客户端(jar lib)。31个客户中有30个没有问题。但三星的一款平板电脑拒绝连接并给出了这样的死机: Android:4.4.4制造商:三星型号:SM-T533-日期:Mon Aug 03 09:49:03 CEST 2015 ApiUtils类:

  • URI 方法 URI() string 返回当前客户端使用的服务器地址。 SetURI 方法 SetURI(uri string) 设置当前客户端使用的服务器地址。如果你想要设置多个服务器地址,请使用 SetURIList 方法代替该方法。 URIList 方法 URIList() []string 返回当前客户端可使用的服务器地址列表。 SetURIList 方法 SetURIList(uriL

  • 客户端事件通过 SetEvent 方法进行设置。 客户端事件有两个,它们分别定义为: type onErrorEvent interface { OnError(name string, err error) }   type onFailswitchEvent interface { OnFailswitch(Client) } 因为 go 语言不需要显式实现接口的特点,所以这两

  • 创建客户端有两种方式,一种是直接使用特化的构造器函数,另一种是使用工厂构造器函数。 第一种方式返回的是具体的客户端结构体指针对象,第二种方式返回的是客户端接口对象。 使用特化的构造器函数创建客户端 特化的构造器函数有下面几个: func NewHTTPClient(uri ...string) (client *HTTPClient) func NewTCPClient(uri ...string