jersey

How can I overload a method with @QueryParam in Jersey/Spring?

为君一笑 提交于 2019-12-12 11:35:12
问题 I would like to overload a method with the @QueryParam but everytime I try to execute this code it throws: SEVERE: Exception occurred when intialization com.sun.jersey.spi.inject.Errors$ErrorMessagesException My code is: @GET @Path("/test") @Produces("text/plain") public String getText(@QueryParam("PID") String pid) { return pid; } @GET @Path("/test") @Produces("text/plain") public String getText(@QueryParam("PID") String pid, @QueryParam("NAME") String name) { return pid + name; } 回答1: No

Swagger UI causing HTTP 406 Not Acceptable response for operations producing content types other than json

こ雲淡風輕ζ 提交于 2019-12-12 10:54:34
问题 I have a REST API published with Jersey and documented with Swagger, I also have a Swagger UI installation consuming that API. Almost all my operations produce application/json and work as expected, except for one GET operation that produces: 'text/plain;charset=utf-8' When I try to call the service from the Swagger UI, the server logs a javax.ws.rs.NotAcceptableException and returns a 406 response. If I call the same service from a REST client it works as expected. @GET @Path("/text")

javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: JSON support in Java REST Webservices with Jersey

送分小仙女□ 提交于 2019-12-12 10:44:20
问题 Okay, this question has probably been asked before, but on all sites I've looked the explanation on "how to do this" tells me I'm doing it completely right. I know I'm not, as I get a 500 server error on my localhost tomcat and I get the following error in my server logs: javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class com.myapp.domain.Location, and Java type class com.myapp.domain.Location, and MIME media type application/json

Jersey serialization/deserialization issue: abstract types can only be instantiated with additional type information

淺唱寂寞╮ 提交于 2019-12-12 10:43:56
问题 I'm using jersey for both serialization and deserialization. I've made REST channel on WebLogic using jersey. I have result object with contains abstract class. Jersey adds to the result metadata with this class'es implementation name: {"order":{"@type":"installationOrder", However, the same jersey, when using to deserialize this data, is screaming the following: Caused by: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of ocl.mobile.service.data.order.DetailedOrder

JAX-RS: How to extend Application class to scan packages?

妖精的绣舞 提交于 2019-12-12 10:33:15
问题 Currently, I do something similar to import javax.annotation.Nonnull; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; import java.util.Collections; import java.util.HashSet; import java.util.Set; @ApplicationPath("oauth") public class OAuthApplication extends Application { final Set<Class<?>> classes = new HashSet<>(); @Nonnull @Override public Set<Class<?>> getClasses() { classes.add(RegisterResource.class); return Collections.unmodifiableSet(classes); } } No if I

How to specify multiple package names for service classes in REST web service using Jersey

允我心安 提交于 2019-12-12 10:29:40
问题 How do I specify multiple <param-value> for a given <param-name> under servlet's <init-param> tag. Following is my web.xml file: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>com.vogella.jersey.first</display-name> <servlet> <servlet-name>Jersey REST

Displaying data using AngularJS

跟風遠走 提交于 2019-12-12 10:23:40
问题 I am trying to represent some data taken from database in a table. I am using jersey as back-end and I have tested it in Postman that it works. The problem is I cannot display my data in the table in front-end, when I use AngularJS. It only shows me a blank table, without data at all. I am pretty new to AngularJS and I really want anyone of you to help me find the problem with my piece of code below. list_main.js angular.module('app', []) .controller('ctrl', function($scope, $http){ $scope

@DefaultValue in JAX-RS for dates: now() and MAX

半世苍凉 提交于 2019-12-12 10:07:35
问题 I have a query parameter as following: @GET public Response myFunction(@QueryParam("start") final LocalDate start, @QueryParam("end") final LocalDate end) { ... } For this, I created a ParamConverter<LocalDate> which converts a string to a date, and vice versa. Now I want to use @DefaultValue annotation to declare a default value. I have two special default values: today (for start ) the maximum value/infinity (for end ) Is it possible to use the @DefaultValue annotation for this? How? 回答1:

File upload services using jersey in tomcat without maven

烂漫一生 提交于 2019-12-12 09:57:55
问题 I want to upload images into server using restful jersey web services.I have included jersey-multipart-1.9.jar , jersey-bundle-1.14.jar and asm-3.3.1.jar jar files and I am not using Maven . Below code snippet for upload function. @POST @Path("/uploadImage") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) { String filePath = SERVER_UPLOAD_LOCATION

Running Jersey on Grizzly on Linux and Windows

天大地大妈咪最大 提交于 2019-12-12 09:37:32
问题 I come from a Windows .NET background, but am trying to expand my expertise, and so have picked up a few Java projects. Currently, I'm trying to create a REST API, and so I decided to go through the walk through for Jersey here: http://jersey.java.net/nonav/documentation/latest/getting-started.html I've gotten the Hello World project to work fine in Windows (using NetBeans and Maven), however when I try to do the same exact thing in Ubuntu (again using NetBeans and Maven) I get the following