jersey

How to submit multiple entities to the post method from jersey client program?

时光毁灭记忆、已成空白 提交于 2019-12-29 08:58:09
问题 I am trying to pass multiple entities to the web service method. The web service method has two parameters of pojo entity type. I am able to post only one entity to the web service method. I am unable to post multiple entities to the web service method. Server side code: @POST @Path("/test") @Produces(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_XML) public void testMethod(Emp emp, Student stud){ ... } Client side code: ... ... Emp emp = new Emp; Student stud = new Student();

SEVERE: A message body writer for Java class java.util.ArrayList and MIME media type application/json was not found

百般思念 提交于 2019-12-29 08:27:31
问题 I am testing RESTful services and when I execute I am getting exceptions although I have the following jars in my class path(WEB-INF/lib), I am not using Maven and my JDK version is 1.5. Other questions regarding this issue didn't help to resolve the problem. Code snippet @GET @Produces("application/json") //@Produces({MediaType.APPLICATION_JSON}) tried this, didn't work either public List<Emp> getEmployees() { List<Emp> empList = myDAO.getAllEmployees(); log.info("size " + empList.size());

Jersey-request for authentication

╄→гoц情女王★ 提交于 2019-12-29 08:16:28
问题 I have a working JavaEE 6 web application on Glassfish, this application already has a JSF frontend and has its authentication mechanism((Using CDI and annotation based security) So there is a login screen, user enters username password, press login button and Java EE authentication process begins. Now I want to "also" expose some of my service classes as a REST service (I will use Jersey probably), so it can also be reached from a mobile device. But what worries me is the login part. I will

Inject not working for nested objects[Jersey 2.22.1]

巧了我就是萌 提交于 2019-12-29 08:14:09
问题 I have a Jersey resource with a facade object injected. This is configured in my ResourceConfig and the facade gets injected fine. The facade contains a DAO class which also should be injected and is configured in the same ResourceConfig . Now to my problem; the DAO class is null. Thus, not injected. @ApplicationPath("/service") public class SystemSetup extends ResourceConfig { public SystemSetup() { packages(false, "com.foo.bar"); packages("org.glassfish.jersey.jackson"); register

Inject not working for nested objects[Jersey 2.22.1]

爷,独闯天下 提交于 2019-12-29 08:14:08
问题 I have a Jersey resource with a facade object injected. This is configured in my ResourceConfig and the facade gets injected fine. The facade contains a DAO class which also should be injected and is configured in the same ResourceConfig . Now to my problem; the DAO class is null. Thus, not injected. @ApplicationPath("/service") public class SystemSetup extends ResourceConfig { public SystemSetup() { packages(false, "com.foo.bar"); packages("org.glassfish.jersey.jackson"); register

Using JaaS with Jersey on Grizzly

可紊 提交于 2019-12-29 08:13:09
问题 I'm trying to find a simple, flexible way to add JaaS authentication to REST. I found a post that I think leads me in the right direction (See StevenC's answer). It sounds like the servlet container is responsible for security, not the Jersey code itself. I like this idea, but need a little guidance on implementation. Grizzly is my servlet container and I want to configure it to use JaaS for authentication. For now, a simple username/password combination would be fine, and hard-coding the

Tomcat, JAX-RS, Jersey, @PathParam: how to pass dots and slashes?

风格不统一 提交于 2019-12-29 07:25:44
问题 Having a method like this: @GET @Path("/name/{name}") @Produces(MediaType.TEXT_PLAIN) public String getProperty(@PathParam("name") String name) { System.out.println(name); } How do I pass a value like "test./test"? /name/test./test gives HTTP 404 /name/test.%2Ftest gives HTTP 400 /name/test.%252Ftest prints test%2Ftest But if I do name = URLDecoder.decode(name); it prints /test and the first part of test. disappears. There is one or two questions like this already but they are old and there

Getting ssl.SSLHandshakeException when using REST client with header but works fine with PostMan

折月煮酒 提交于 2019-12-29 07:14:12
问题 I have an external REST resource with below details: The URL: abc.com/orders (the domain is with https ) I need to pass UserID as an HTTP header with key "user" value is "abcd" This would return an JSON response I am using below Java code for this: try { Client client = Client.create(); WebResource webResource = client.resource("abc.com/orders"); ClientResponse response = webResource.header("user", "abcd").accept("application/json") .get(ClientResponse.class); if (response.getStatus() != 200)

Getting ssl.SSLHandshakeException when using REST client with header but works fine with PostMan

雨燕双飞 提交于 2019-12-29 07:13:33
问题 I have an external REST resource with below details: The URL: abc.com/orders (the domain is with https ) I need to pass UserID as an HTTP header with key "user" value is "abcd" This would return an JSON response I am using below Java code for this: try { Client client = Client.create(); WebResource webResource = client.resource("abc.com/orders"); ClientResponse response = webResource.header("user", "abcd").accept("application/json") .get(ClientResponse.class); if (response.getStatus() != 200)

JAX-RS in relation to Jersey and JSRs

天涯浪子 提交于 2019-12-29 06:45:13
问题 I'm trying to get my head around some concepts in Java: JSR(s): describe specifications, but carry no actual implementations. E.g. http://jsr311.java.net/ is the "home" for "Java™ API for RESTful Web Services". It serves as a common reference for all implementations of JSR-311. One can download the interfaces (?) of JSR-311 from http://mvnrepository.com/artifact/javax.ws.rs/jsr311-api, however, unless you are implementing JSR-311 by yourself these have no particular value? JSR(s) will usually