Resource matching issues
by Jonas Konrad
Hey everyone,
Today I stumbled upon an issue in resource matching and I'm not sure if
this is a bug or working as specified (but breaking without warning).
This is the test case:
import java.io.IOException;
import java.util.*;
import javax.ws.rs.*;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
public class Testcase {
public static void main(String[] args) throws IOException {
UndertowJaxrsServer server = new UndertowJaxrsServer();
server.deploy(new Application() {
@Override
public Set<Class<?>> getClasses() {
return new HashSet<>(Arrays.asList(A.class, B.class));
}
});
server.start();
}
@Path("/b")
public static class A {
@GET
@Path("{x}")
public Response c(@PathParam("x") int ignored) {
return Response.serverError().build();
}
}
@Path("/")
public static class B {
@GET
@Path("b/{x}/c")
public Response c(@PathParam("x") int ignored) {
return Response.ok("c").build();
}
}
}
Without A.class `curl -v http://localhost:8081/b/1/c` works as expected
(yields "c"). With A.class included this leads to a 404.
I've narrowed this down to this method:
https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/...
; Apparently, if a *class* resource matches (i.e. A) all other class
resources are completely disregarded, even if the matched class can't
actually handle the request.
Looking at the jax-rs spec at
http://download.oracle.com/otn-pub/jcp/jaxrs-2_0-fr-eval-spec/jsr339-jaxr...
, section 3.7.2, point 1.f, I'm thinking this may actually be the
intended behaviour, but the terminology is a bit confusing to me.
Is this a bug or a feature? If it's working as intended, would it be
feasible to add a warning when registering such a "dead" resource
method? This is a really subtle issue that was a pain to debug :)
Thanks,
- Jonas Konrad
8 years, 3 months
Deploying a Jersey Servlet and using the war file's own web.xml for deployment
by Filip Panovski
Hello everyone,
I have a couple of API Services that I would like to combine with a main
'framework' of sorts that would load the services as needed. The services
themselves however, should be as decoupled from each other as possible (to
be able to independently develop them ala microservice architecture).
Basically, I would like to:
- Start up a WebAppContext for my Framework 'loader'
- Deploy the various services using .war files of all the services
- Have the services' own web.xml configuration descriptors be in effect so
that I can set per-service configurations
Is this possible? If so, how can it be done? If not, what would be the best
way to accomplish something similar? Thanks for any responses.
Best,
Filip
8 years, 3 months
issue with restEasy client and jackson2 provider
by Mario Rodriguez
Hi, I have a Java REST webservice that connects to a Node.js REST service via restEasy client. While I was using the old org.codehaus.jackson.* version it was working fine, then I'm trying to update to jackson2 provider but now I'm getting an error when the restEasy client on my Java app is trying to post a message to the nodeJS service.
Exception in thread "Thread-13" java.lang.NoSuchMethodErr
or: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/refl
ect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;
at com.fasterxml.jackson.module.jaxb.JaxbAnnotati
onIntrospector._fullSerializationType(JaxbAnnotationIntrospector.java:1474)
at com.fasterxml.jackson.module.jaxb.JaxbAnnotati
onIntrospector._findContentAdapter(JaxbAnnotationIntrospector.java:1410)
at com.fasterxml.jackson.module.jaxb.JaxbAnnotati
onIntrospector.findSerializationContentConverter(JaxbAnnotationIntrospector.java:
800)
at com.fasterxml.jackson.databind.introspect.Anno
tationIntrospectorPair.findSerializationContentConverter(AnnotationIntrospectorPa
ir.java:372)
at com.fasterxml.jackson.databind.ser.std.StdSeri
alizer.findConvertingContentSerializer(StdSerializer.java:417)
at com.fasterxml.jackson.databind.ser.std.AsArray
SerializerBase.createContextual(AsArraySerializerBase.java:198)
at com.fasterxml.jackson.databind.SerializerProvi
der.handlePrimaryContextualization(SerializerProvider.java:928)
at com.fasterxml.jackson.databind.SerializerProvi
der.findPrimaryPropertySerializer(SerializerProvider.java:626)
at com.fasterxml.jackson.databind.ser.impl.Proper
tySerializerMap.findAndAddPrimarySerializer(PropertySerializerMap.java:72)
at com.fasterxml.jackson.databind.ser.BeanPropert
yWriter._findAndAddDynamic(BeanPropertyWriter.java:834)
at com.fasterxml.jackson.databind.ser.BeanPropert
yWriter.serializeAsField(BeanPropertyWriter.java:650)
at com.fasterxml.jackson.databind.ser.std.BeanSer
ializerBase.serializeFields(BeanSerializerBase.java:678)
at com.fasterxml.jackson.databind.ser.BeanSeriali
zer.serialize(BeanSerializer.java:157)
at com.fasterxml.jackson.databind.ser.std.Collect
ionSerializer.serializeContents(CollectionSerializer.java:149)
at com.fasterxml.jackson.databind.ser.std.Collect
ionSerializer.serialize(CollectionSerializer.java:112)
at com.fasterxml.jackson.databind.ser.std.Collect
ionSerializer.serialize(CollectionSerializer.java:25)
at com.fasterxml.jackson.databind.ser.DefaultSeri
alizerProvider.serializeValue(DefaultSerializerProvider.java:253)
at com.fasterxml.jackson.databind.ObjectWriter$Pr
efetch.serialize(ObjectWriter.java:1425)
at com.fasterxml.jackson.databind.ObjectWriter.wr
iteValue(ObjectWriter.java:930)
at org.jboss.resteasy.plugins.providers.jackson.R
esteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:207)
at org.jboss.resteasy.core.interception.AbstractW
riterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:131)
at org.jboss.resteasy.core.interception.AbstractW
riterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:120)
at org.jboss.resteasy.plugins.interceptors.encodi
ng.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)
at org.jboss.resteasy.core.interception.AbstractW
riterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:124)
at org.jboss.resteasy.client.jaxrs.internal.Clien
tInvocation.writeRequestBody(ClientInvocation.java:370)
at org.jboss.resteasy.client.jaxrs.engines.Apache
HttpClient4Engine.writeRequestBodyToOutputStream(ApacheHttpClient4Engine.java:558
)
at org.jboss.resteasy.client.jaxrs.engines.Apache
HttpClient4Engine.buildEntity(ApacheHttpClient4Engine.java:524)
at org.jboss.resteasy.client.jaxrs.engines.Apache
HttpClient4Engine.loadHttpMethod(ApacheHttpClient4Engine.java:423)
at org.jboss.resteasy.client.jaxrs.engines.Apache
HttpClient4Engine.invoke(ApacheHttpClient4Engine.java:281)
at org.jboss.resteasy.client.jaxrs.internal.Clien
tInvocation.invoke(ClientInvocation.java:436)
at org.jboss.resteasy.client.jaxrs.internal.proxy
.ClientInvoker.invoke(ClientInvoker.java:102)
at org.jboss.resteasy.client.jaxrs.internal.proxy
.ClientProxy.invoke(ClientProxy.java:76)
at com.sun.proxy.$Proxy56.saveOrders(Unknown Sour
ce)
at com.llbean.order.history.extractor.writer.Serv
iceOrderWriter.writeOrders(ServiceOrderWriter.java:67)
at com.llbean.order.history.extractor.migration.W
orker.execute(Worker.java:29)
at com.llbean.order.history.extractor.migration.A
bstractExtractorTemplate.executeWorkers(AbstractExtractorTemplate.java:43)
at com.llbean.order.history.extractor.migration.A
bstractExtractorTemplate.extract(AbstractExtractorTemplate.java:31)
at com.llbean.order.history.extractor.rest.Initia
tionResource$1.run(InitiationResource.java:48)
at java.lang.Thread.run(Thread.java:745)
I found this page http://stackoverflow.com/questions/21780208/resteasy-and-jackson-incompat... making reference to an incompatibility on earlier versions of restEasy and jackson2, however, I'm using Jackson 2.7 and restEasy 3.0.16.
Here is the gradle build settings:
// RestEasy (Server side JAX-RS implementation)
compile 'org.jboss.resteasy:resteasy-jaxrs:3.0.16.Final'
compile 'org.jboss.resteasy:resteasy-guice:3.0.16.Final'
compile 'org.jboss.resteasy:resteasy-servlet-initializer:3.0.16.Final'
compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.16.Final'
// RESTEasy (JAX-RS client)
compile 'org.jboss.resteasy:resteasy-client:3.0.16.Final'
Any clue what I'm missing ?
Mario Rodríguez
Systems Analyst | Customer Technology Team | L.L.Bean Inc.
CR P: (506) 2201-0183 | US P: (207) 552-6677 ext. 40083
8 years, 4 months