我有一个POJO可以封装一组用于REST API调用的参数。
@XmlRootElement(name="card")
@XmlAccessorType(XmlAccessType.FIELD)
public class SpecificProviderTokenizationRequest implements ITokenizationRequest {
@XmlElement(name="cardNum")
private String cardNumber;
@XmlElement(name="holderName")
private String cardHolderName;
@XmlElement(name="cardExpiry")
private CardExpiry cardExpiry;
@XmlTransient
private String url;
@XmlTransient
private String apiKey;
...
然后我正在使用javax.ws.rs.client.Client
来执行实际的请求。
SpecificProviderTokenizationRequest request;
Response response = wsClient.target(request.getTokenizationServiceHost())
.request()
.header("Authorization", "Basic " + request.getApiKey())
.post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));
但是球衣客户端失败,并显示以下内容:
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.introspect.AnnotatedField.isTransient()Z
at com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.findNameForSerialization(JaxbAnnotationIntrospector.java:956) ~[jackson-module-jaxb-annotations-2.8.8.jar:2.8.8]
at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.findNameForSerialization(AnnotationIntrospectorPair.java:487) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addFields(POJOPropertiesCollector.java:406) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collect(POJOPropertiesCollector.java:243) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.introspect.BasicClassIntrospector.collectProperties(BasicClassIntrospector.java:197) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.introspect.BasicClassIntrospector.forSerialization(BasicClassIntrospector.java:90) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.introspect.BasicClassIntrospector.forSerialization(BasicClassIntrospector.java:15) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.SerializationConfig.introspect(SerializationConfig.java:695) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:133) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1152) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1112) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:471) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:669) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:107) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:851) ~[jackson-databind.jar:2.5.0]
at com.fasterxml.jackson.jaxrs.base.ProviderBase.writeTo(ProviderBase.java:648) ~[jackson-jaxrs-base.jar:2.5.0]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[jersey-common.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[jersey-common.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[jersey-common.jar:na]
at org.glassfish.jersey.filter.LoggingFilter.aroundWriteTo(LoggingFilter.java:302) ~[jersey-common.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[jersey-common.jar:na]
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1128) ~[jersey-common.jar:na]
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:502) ~[jersey-client.jar:na]
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:329) ~[jersey-client.jar:na]
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:242) ~[jersey-client.jar:na]
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:245) ~[jersey-client.jar:na]
这很奇怪,因为我有一些单元和功能测试来检查这些类和代码区域,但是当我在glassfish中部署并运行.war文件时,它会失败。
看起来像jersey客户端无法解决杰克逊依赖关系,因此,它无法找到AnnotatedField.isTransient
方法。
有什么想法吗?有人面对过类似的事情吗?