jersey

My Ajax POST is coming up as an error even though I am returning 200

蓝咒 提交于 2019-12-24 10:47:23
问题 I am making an AJAX post to a Jersey Resource. I build an image and return it. The issue is, no matter what status I return, Ajax thinks it is an error. I can actually use the error message (via error.responseTest) and it works fine. But it is ugly. What do I return to make it a success? I have returned OK(200), Accepted(202) and Created(201). All of them give me an error message but in my Console Network tab, I get a success (green with the proper status). I am returning it like this: return

Set-Cookie header does not set cookie in Internet Explorer

前提是你 提交于 2019-12-24 09:37:52
问题 I'm trying to set a cookie server-side using the Set-Cookie header. Using jersey the cookie is set server side like this: NewCookie cookie = new NewCookie("token", tokenValue, "/", "", 1, "", 3600, new Date(System.currentTimeMillis() + 3600000), false, false); return Response.ok() .cookie(cookie) .build(); My response header in Chrome looks like this: When I try to send another request to the server, to check if the cookie is send back, everything works as expected. The request header looks

Jersey @InjectParam creating a new Object instead of taking from Spring

自闭症网瘾萝莉.ら 提交于 2019-12-24 09:17:06
问题 I have a Jersey Application using Spring I am using the @InjectParam in the hope (and what is written in the documentation) that Jersey would obtain the object from the Spring Container, but it seems Jersey is creating the object instead of asking Spring for it. Is there a way of checking if the Spring IOC is registered with Jersey ? web.xml <?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" xmlns:web

Sending String[] through REST with Jersey

空扰寡人 提交于 2019-12-24 08:49:48
问题 I'm trying to implement a REST webservice with Jersey. I'm using JBoss AS 7.1.1 Final as my webserver. The problem is happening whenever I attempt to use a String[] as part of my method's signature: @Override @POST @Path("/getVersion") public ControllerVersion getVersion(String deviceID, String[] macAddresses) { System.out.println("Received "+deviceID+", and macAddress[0] "+macAddresses[0]); return new ControllerVersion(); } The exception that's being thrown on the server side is as follows:

Request parameters are dropped in Tomcat

浪尽此生 提交于 2019-12-24 05:56:27
问题 Client code: FormDataBodyPart f = new FormDataBodyPart(...); FormDataBodyPart f2 = new FormDataBodyPart(...); MultiPart multiPart = new MultiPart(); multiPart.bodyPart(f); multiPart.bodyPart(f2); //Execute Call WebResource wr = resource().path(Url.X); wr = wr.queryParam("subjectId", "value_something"); ClientResponse response = wr.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, multiPart); Server code: String id = req.getParameter("subjectId"); req is HttpServletRequest -

Issues in JAXRS Rest service using jersey

大城市里の小女人 提交于 2019-12-24 05:11:15
问题 Deployed a demo Rest Service on tomcat 7 using jersey JAXRS API . Developed a resource class @Path("/supportdata") public class SupportDataService { public SupportDataService() { // TODO Auto-generated constructor stub } @GET @Produces(MediaType.APPLICATION_XML) public String getSupportData(){ String xmlSupport=null; xmlSupport="<SupportData><Support><key>path1</key><value>value1</value></Support><Support><key>path2</key><value>value2</value></Support></SupportData>"; return xmlSupport; } }

Rest JAX-RS exception, MessageBodyWriter not found

天涯浪子 提交于 2019-12-24 04:48:05
问题 I am using Jersey 2.13 I get MessageBoddyWriter not found exception when I try to access a resource via a url in a browser. Exception: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List<com.webservices.entity.Book>. I have another method that produces "APPLICATION_XML" and that seems to work fine. @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Book { @XmlElement private String name; @XmlElement private

Overriding @Path at Jersey

…衆ロ難τιáo~ 提交于 2019-12-24 03:52:57
问题 I've been trying to make a Jersey app that takes the following structure from the path: Example 1 (http:// omitted due to stackoverflow restrictions) example.com/source/{source-id}/ example.com/source/ With code (error handling and unneeded code omitted): With code (sum up): @Path("/source/") public class SourceREST { ... @GET public Response getSource() { return Response.ok("Sources List (no field)").build(); } @GET @Path("/{source-id}") public Response getSource(@PathParam("source-id")

Jersey - JerseyTest: Error reading entity from input stream

纵饮孤独 提交于 2019-12-24 03:51:49
问题 I have created a test project in order to learn Jersey. I have created the following classes Book.java (Model), BookDao.java , BookResource.java and so far everything works just fine. My problem is with a JerseyTest i am trying to run ( BookResourceTest.java ). I am using Jackson for JSON serialization. When i run the test i get this error: Error reading entity from input stream . This is the console output: ------------------------------------------------------- T E S T S -------------------

how to customize Date in jackson serialization , @JsonSerialize not working

喜夏-厌秋 提交于 2019-12-24 03:38:12
问题 i want to change the date format in a json that is delivered by a java rest webservice, that is because the json have the dates like this: 2019-05-23T06:00:00Z[UTC] , so the client confuse the [UTC] with an array, because of the '[' and ']' im using glassfish 5 ,jax-rs , jackson 2.9.4 databind, . i have tried to use @JsonSerialize(using = CustomXSerializer.class) in the model object and didn work, also @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="MM-dd-yyyy",timezone="CET") in the