Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用resteasy时无法构造抽象类型的实例_Java_Jackson_Wildfly_Resteasy - Fatal编程技术网

Java 使用resteasy时无法构造抽象类型的实例

Java 使用resteasy时无法构造抽象类型的实例,java,jackson,wildfly,resteasy,Java,Jackson,Wildfly,Resteasy,我有一个扩展了抽象类XjafAgent的类,该抽象类实现了一个名为Agent的接口 我在Wildfly上运行并利用resteasy库的应用程序上执行以下代码: ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget rtarget = client.target(url); ConnectionManagerRestAPI rest = rtarget.proxy(ConnectionManag

我有一个扩展了抽象类XjafAgent的类,该抽象类实现了一个名为Agent的接口

我在Wildfly上运行并利用resteasy库的应用程序上执行以下代码:

ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget rtarget = client.target(url);
ConnectionManagerRestAPI rest = rtarget.proxy(ConnectionManagerRestAPI.class);
rest.moveAgent(getAgentReference(aid));
我的REST API方法标题moveAgent定义如下:

public void moveAgent(Agent agent);
因此,它希望得到一些实现代理接口的东西(这是一个扩展我的XjafAgent抽象类的类)。但是,当我执行此代码时,会出现以下错误:

problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
现在,我发现通过向抽象类添加以下代码行,解决了一些问题:

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
我尝试将此注释添加到我的XjafAgent抽象类以及代理接口中,但没有成功


所以主要的问题是我没有发送一个具体类的对象,而是我的方法接受一个实现给定接口的对象。你知道我该怎么解决这个问题吗?我愿意接受任何建议。

但当然,您发送的是一个具体类的对象,因为您无法获得任何其他类型的对象。方法签名只是没有指定哪个类——这就是问题所在。远程端不需要知道调用对象上的方法的实现类,但它需要知道如何从请求中反序列化对象?