jersey-2.0

Why do I get static text/html when returning a 404 Response with Java / Jersey?

▼魔方 西西 提交于 2019-12-02 11:29:18
问题 I'm working with Java, Jetty and Jersey 2.18 (latest for now) hosted on a Google App Engine. Let say I have a service such that @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{userId}") public Response getUser(@PathParam("userId") String userId) { ... } When I do: return Response.ok() .entity(user) .build(); I correctly receive an application/json content-type and body. But when I do: return Response .status(404) .entity(new ResponseModel(100, "user not found")) .build(); same as for

JAX-RS Web Service works fine on localhost. But when run on the server it gives an error

本小妞迷上赌 提交于 2019-12-02 11:03:42
Hi I wrote a web service using jax-rs and spring mvc. I am using jersey plugin to create a service. When I run it on the localhost, the data is retrieved successfully and when I host the service on the server it gives the bellow error. type Exception report message Servlet.init() for servlet lk.slsi.config.restConfig threw exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet.init() for servlet lk.slsi.config.restConfig threw exception org.apache.catalina.authenticator.AuthenticatorBase

Spring-Boot Jersey: allow Jersey to serve static content

限于喜欢 提交于 2019-12-02 10:27:06
The application uses JDK 8, Spring Boot & Spring Boot Jersey starter and is packaged as a WAR (although it is locally run via Spring Boot Maven plugin). What I would like to do is to get the documentation I generate on the fly (at build time) as a welcome page. I tried several approaches: letting Jersey serving the static contents by configuring in application.properties the proper init parameter as described here introduce a metadata-complete=false web.xml in order to list the generated HTML document as a welcome-file. None of that worked out. I would like to avoid having to enable Spring MVC

Spring boot Jersey with groovy/gradle fails on startup

拜拜、爱过 提交于 2019-12-02 07:46:16
We're just starting a new project, and are looking into spring-boot for kickstarting our development. spring-boot seems powerful, but there's some magic going on that we yet don't understand. I've cloned the spring-boot samples and ran the Jersey Example. So far so good. I then converted this to Groovy/Gradle. relevant sections of the build script looks like this . . buildscript { repositories { jcenter() // maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io/milestone" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.0.M2")

JsonMappingException: Can not find a deserializer for non-concrete Map type

冷暖自知 提交于 2019-12-02 07:44:34
String str = commonClient.authorizedRequestBuilder(commonClient.webTarget .path("/apps/get_current_version/default/"+appName+"/"+appName) .queryParam("object_type", "app")) .accept(MediaType.APPLICATION_JSON_TYPE) .get() .readEntity(String.class); i get str = {"versions": {"ap": "Not Set", "am": "topic-test-publisher-1.0.16", "il": "topic-test-publisher-1.0.16", "row": "topic-test-publisher-1.0.49"}, "provider": "gce"} Then i have changed to this code Version version = commonClient.authorizedRequestBuilder(commonClient.webTarget .path("/apps/get_current_version/default/"+appName+"/"+appName)

Why do I get static text/html when returning a 404 Response with Java / Jersey?

こ雲淡風輕ζ 提交于 2019-12-02 07:09:50
I'm working with Java, Jetty and Jersey 2.18 (latest for now) hosted on a Google App Engine. Let say I have a service such that @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{userId}") public Response getUser(@PathParam("userId") String userId) { ... } When I do: return Response.ok() .entity(user) .build(); I correctly receive an application/json content-type and body. But when I do: return Response .status(404) .entity(new ResponseModel(100, "user not found")) .build(); same as for returning any 4XX or 5XX status, I receive a text/html content-type along with this HTML body: <html> <head

Resource model validation failure in JerseyTest for Spring-Jersey application

ぐ巨炮叔叔 提交于 2019-12-02 02:52:23
问题 I have an annotated Spring-Jersey application. I am trying to set up unit test for my controllers using JerseyTest . I am getting the following errors on running the test that I am not able to figure out. What have I missed? SEVERE: Following issues have been detected: WARNING: No injection source found for a parameter of type public com.example.services.dto.UnitDto com.example.apis.UnitResource.getUnits(com.example.services.dto.PointDto) throws com.example.exceptions.PointOutsideBounds at

Resource model validation failure in JerseyTest for Spring-Jersey application

丶灬走出姿态 提交于 2019-12-02 01:39:51
I have an annotated Spring-Jersey application. I am trying to set up unit test for my controllers using JerseyTest . I am getting the following errors on running the test that I am not able to figure out. What have I missed? SEVERE: Following issues have been detected: WARNING: No injection source found for a parameter of type public com.example.services.dto.UnitDto com.example.apis.UnitResource.getUnits(com.example.services.dto.PointDto) throws com.example.exceptions.PointOutsideBounds at index 2. Validation of the application resource model has failed during application initialization. [

Limit path media type mappings in Jersey

血红的双手。 提交于 2019-12-02 00:45:08
问题 I have configured MEDIA_TYPE_MAPPINGS for my Jersey apps. Unfortunately, this causes some trouble with a generic upload service in my app. @PUT @Path("files/{filename}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response uploadFile( @PathParam("filename") @NotNull @Size(max = 240) String filename, DataSource dataSource) If someone uploads .../files/file.xml the extension is chopped of. Is there a way to tell Jersey to skip that filtering for this resource?

DELETE Request with Payload or Form Data causes Bad Request

牧云@^-^@ 提交于 2019-12-01 22:53:15
I am building a RESTful Web Service with Java Jersey 2.17. The Client for it. I am developing with ExtJS 5. My classes on the service Main.java public class Main { public static final String BASE_URI = "http://localhost:8080/app/rest/"; public static HttpServer startServer() { final ResourceConfig rc = new ResourceConfig(); rc.packages(true, "app"); rc.register(ResponseCorsFilter.class); return GrizzlyHttpServerFactory.createHttpServer(URI.create(Main.BASE_URI), rc); } public static void main(final String[] args) throws IOException { final HttpServer server = Main.startServer(); System.out