jersey

Jersey LoggingFilter with log4j

戏子无情 提交于 2019-12-12 08:41:52
问题 I have a rest service developed with jersey, I have a ContainerRequestFilters for print the request, as follows: <init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value> </init-param> and I have logger in the post methods using log4j. But the LoggingFilter print in the log different log4j. Is there any way that LogginFilter use the log4j's configuration? I tried this in the log4j.xml

Jersey java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

落花浮王杯 提交于 2019-12-12 08:38:17
问题 I'm trying to make a web-service with Tomcat and Eclipse using jersey library. This is my service class: package com.gontuseries.university; import javax.ws.rs.core.MediaType; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/university") public class UniversityRestWs { @GET @Produces(MediaType.TEXT_HTML) public String getHtmlUniversityInfo(){ return "<html><body>test</body></html>"; } @GET @Produces(MediaType.TEXT_PLAIN) public String getTextUniversityInfo

Jersey Multipart Client Upload

蓝咒 提交于 2019-12-12 08:37:54
问题 I've designed a multipart Jersey REST service as below to receive a multipart request (file uploads) and save the file in a disk location: @POST @Path("/Upload") @Produces(MediaType.TEXT_HTML) @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadFile(@FormDataParam("file") InputStream inputStream, @FormDataParam("file") FormDataContentDisposition contentDisposition) { System.out.println("Method Entry"); System.out.println(contentDisposition.getFileName()); String result = "not Success

JERSEY: How to retrieve the calling IP or URI using injection annotation?

亡梦爱人 提交于 2019-12-12 08:24:54
问题 I have a REST- Server here using JERSEY. I must log the IP (better the DNS) of the calling client. Can somebody point a direction which injection annotations to use ? Searched "@Context", but could not find anything fitting. Thanks Gerd 回答1: you could add @Context HttpServletRequest request as a parameter to your request handler method. And then get a hold of the client IP with request.getRemoteAddr() 回答2: In case you use Grizzly-Jersey combo, thats the way to do it: @Context private java

How to generate JSON from a Jersey resource?

北慕城南 提交于 2019-12-12 08:24:18
问题 I'm using Jersey and want to output the following JSON with only the fields listed: [ { "name": "Holidays", "value": "http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic" }, { "name": "Personal", "value": "http://www.google.com/calendar/feeds/myprivatefeed/basic" } ] If I must, I can surround that JSON with {"feeds": ... }, but having this be optional would be best. I want to pull this information from a list of CalendarFeeds that are stored in a Member

Jersey Multipart - Missing start boundary

▼魔方 西西 提交于 2019-12-12 08:09:11
问题 I have a server application with jersy 2.13 with Netty and I try to upload a file with "multipart/form-data" and I got this error. The Error Message: 7605 10:01:49.309 [child-group-3-1] org.jvnet.mimepull.MIMEParsingException: Missing start boundary 66242 08:57:42.713 [child-group-3-1] ERROR ROOT - No codec available to display error for 'Content-Type:multipart/form-data; boundary=----webkitformboundaryv4kegleyi4tkjp8j' My dependencies compile group: "org.glassfish.jersey.core", name: "jersey

How to get a session Object in the ContainerRequest to can use the annotation @RolesAllowed(Role_user)?

荒凉一梦 提交于 2019-12-12 07:57:05
问题 I am building an application using App Engine with Jersey. I would like use the annotation @RolesAllowed(Role_user) who permit to create a filter in the request. The problem is that we need to configure the class SecurityContextFilter . My objective is to get the id of the user stored in a session to then check their role directly in the function : public ContainerRequest filter(ContainerRequest request) of my class SecurityContextFilter . I need to inject HttpRequest to get the session, but

How to authenticate users in Jersey

孤者浪人 提交于 2019-12-12 07:13:20
问题 I am writing a RESTful application in Java using Jersey, and i need to authenticate users. I know i can specify the roles in the resource using the annotations @RolesAllowed, but i can't understand how a user is associated to a specific role. The client sends username and password in this way HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(user, password); Client client = ClientBuilder.newClient(); client.register(feature); WebTarget target = client.target(baseUrl).path

How can I map semicolon-separated PathParams in Jersey?

孤街浪徒 提交于 2019-12-12 07:13:10
问题 Is there a way to use this parameter style: /products/123;456;789 in JAX-RS with Jersey? If I use PathParam, only the first parameter in the list is returned. I tried to escape the semicolon but then Jersey returns only "123;456;789" as the value of the first parameter list entry I declared the GET method as public List<Product> getClichedMessage(@PathParam("ids") List<String> idList) Update: I am referring to the Jersey user guide for Jersey 1.1.5: In general the Java type of the method

MOXy adds type and uses toString?

筅森魡賤 提交于 2019-12-12 06:40:53
问题 Disclaimer: I'm new to all this, so my terminology may be wrong I've got some Java POJO's I want to serialize to JSON & XML. I'm using MOXy 2.5.0 for JSON and Jersey 2.4.1. @XmlRootElement class Root { // @XmlElements({@XmlElement(name = "destination_address", type = LatLong.class), // @XmlElement(name = "destination_address", type = Polygon.class)}) public Object[] destination_addresses; } public class LatLong { public double lat, lng; } public class Polygon { protected List<LatLong> points