Selecting MessageBodyWriter seems to ignore priority given a specific type match
by Steven Schlansker
Hi Resteasy users, [ apologies for the re-post, sent from wrong email the first time ]
I'm a happy user of Resteasy + Jackson for Json processing.
Recently, I had the misfortune of attempting to serialize a basic String:
client.post(Entity.json("Test"));
if you call Jackson directly, it does the right thing:
mapper.writeValueAsString("Test") => "\"Test\""
However, much to my surprise, when sending it via JAX-RS client, it is written as a bare word without quotes -- and is rejected server-side.
After some debugging, I realized that both StringTextStar and JacksonJsonProvider were ending up with Priorities.USER and being seen as equivalent.
No good! So I changed my registration:
context.register(new JacksonJsonProvider(myMapper), Integer.MAX_VALUE);
I then proceeded to triumphantly ... observe the same test failure as before!
Dug quite a bit further in, and it seems that the selection process in MediaTypeMap$TypedEntryComparator
has the unfortunate property that it will select (via compareTypes) a *less priority* MessageBodyWriter if the type is a tighter bound on the Entity.
So in my case, I get
StringTextStar -> String.class@5000
JacksonJsonProvider -> Object.class(a)Integer.MAX_VALUE
and the TypedEntryComparator selects StringTextStar since String is-assignable to Object, despite my attempt at an ultimate priority registration.
How do I fix this? Preferably without removing StringTextStar entirely, as I'm sure that will break something else (reading error messages perhaps).
Thanks for any advice,
Steven
1 day, 7 hours
Migrating existing Rest Easy Project to SpringBoot
by Lloyd Fernandes
Team,
I am trying to integrate my existing project from RestEasy implementation to SpringBoot 2.x
My current project settings has two application classes(javax.ws.rs.core.Application): App1 and App2
Three Provider Classes: P1, P2 and P3
The providers are registered to the applications as follows:
App1 --> P1, P2
App2 --> P1, P3
Applications are registered by updating the singletons set in the Application Constructors of App1 and App2. Example:
public App1{ singletons.add(new P1()); singletons.add(new P2());}
I was referencing the RestEasy - SpringBootStarter :https://github.com/resteasy/resteasy-spring-boot/blob/main/mds/USAGE.md. Had the following questions after reading the description:
1. I do not see the use of such singletons recommended anymore. So how do I ensure, that the Providers are registered to the correct Application?
2. How do i convert the context param, filter-mapping, login-config, security constraint configurations defined in web.xml to the equivalent SpringBoot configurations that would work with Rest Easy.
3. What has more precedence the SpringBoot Security modules or the RestEasy security constraints?
2 months, 4 weeks
RESTEASY003210: Could not find resource for full path
by Edoardo Panfili
Hi,
I am switching from (tomcat8+java8+resteasy3.6) to (tomcat9+java11+resteasy4)
All seem works fine except the home page of my application.
If I point the browser to "http://localhost:8080/myApp/" this is the answer:
"RESTEASY003210: Could not find resource for full path: http://localhost:8080/myApp/"
Don't know why resteasy is responding outside the application path, can someone help me?
this is my configuration:
---------------------------------
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/ws")
public class WebServices extends Application {
}
---------------------------------
In my pom.xml file I am using this dependencies:
org.jboss.resteasy:resteasy-jaxrs-all:4.0.0.Final
org.jboss.resteasy:resteasy-jackson2-provider:4.0.0.Final
org.jboss.resteasy:resteasy-servlet-initializer:4.0.0.Final
thank you
Edoardo
2 months, 4 weeks