jersey

How to receive client certificate in an HTTP request?

吃可爱长大的小学妹 提交于 2019-12-12 03:41:55
问题 I have generated self signed SSL certificate and given to a client. Every time, the client sends a REST request, I do client certificate authentication on the server. I need to get get data of the certificate in the java code. How do I do that? I have used jersey framework. 回答1: You can use @Context Annotation for extracting HttpServletRequest. @POST @Path("/getHelloWorld") @Consumes(MediaType.APPLICATION_JSON) public String helloWorld(@Context HttpServletRequest httpRequest) {

tomcat gives http404 error when used to test jersey java web service

喜你入骨 提交于 2019-12-12 03:31:43
问题 I have a jersey java dynamic web project...a web service which i think is laid out correctly (hoping im wrong though). This web service runs off tomcat8.5 server on my win 10 laptop. When Tomcat is manually started in services I can hit its home page at localhost:8081. When i run my web service in eclipse i am denied with http 404 error 'request resource isnt available'. I cant even hit the localhost:8081 the same way i can when i start it manually and i cant see it started in 'services'..

Unable to marshal type “java.util.HashMap” while hitting the resource with json

风格不统一 提交于 2019-12-12 03:28:27
问题 I have written a RESTful resource method which produces application/json and application/xml which is defined at class level and below is my method: @GET @Path("testing/getNames") public Map<Long, String> getNames(@QueryParam("list") List<Long> list) { // return invoking ejb method and return map } When i hit this resource with json produces, it's giving the response back but for format=format.xml i am getting the following exception: Caused by: javax.xml.bind.MarshalException - with linked

Allow cross domain request to jersey web services

点点圈 提交于 2019-12-12 03:28:21
问题 Facing issue related to allowing cross domain requests in jersey. I tried to implement com.sun.jersey.spi.container.ContainerResponseFilters , but not able to configure it. Getting exception, when try to send the request from browser. org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [JAX-RS Servlet] in context with path [/crawlerweb] threw exception [Servlet execution threw an exception] with root cause java.lang.AbstractMethodError: javax.ws.rs.core

REST- Jersey - Exception obtaining parameters

笑着哭i 提交于 2019-12-12 03:24:01
问题 Here is my ajax call: uploadExcel : function(jsonData,success, error) { var url = "/TestProject/test/Uploader; $.ajaxFileUpload({ url : url, secureuri : false, fileElementId : 'FileUpload', contentType : 'multipart/form-data', dataType : 'jsonString', processData : false, type : 'POST', data: jsonData, success : success, error : error }); } Java Method signature: @Path("/Uploader") @POST @Consumes('multipart/form-data') public String validateAndUpload(@FormDataParam("FileUpload") byte[]

namespace prefix for generated jersey rest response xml

倖福魔咒の 提交于 2019-12-12 03:21:44
问题 I'm generating rest responses (using Jersey) from jaxb models. And for some of the responses, the generated XML has namespace prefix (ns2) added to the namespace attribute although they all exists in the same namespace. But for others, it is perfectly fine. With my analysis, I think it happens when there is a complex element (another jaxb model) is being used inside one. But all these models are declared in same namespace in package-info.java. Here is the code. XYZModel.class package int.xyxp

REST - Jersey -Providing Cross Site Access

眉间皱痕 提交于 2019-12-12 03:05:15
问题 I guess I am trying to make a few design choices regarding the REST API I'm working on. -Is it a good idea to provide cross-site access? In other words, should I allow for JSONP responses. I'm leaning toward providing JSOP responses, because I'm guessing that if I don't allow for JSONP, then a javascript client running in a browser will not be able to access my API. If you have any experience For or Against this idea, I'd appreciate it. -Using Jersey, I can provide JSONP response by

SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.jersey.jaxb.Todo, genericType=class com.jersey.jaxb.Todo

梦想的初衷 提交于 2019-12-12 03:04:15
问题 I am trying to create a RESTful web-service and I created one but I am getting a MessageBodyWriter not found for media type=application/json error My Todo class: package com.jersey.jaxb; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.pojomatic.Pojomatic; import org.pojomatic.annotations

How to find what version of EclipseLink my Eclipse Project is using?

假装没事ソ 提交于 2019-12-12 02:59:53
问题 I have a Maven jersey-quickstart-webapp Project I am developing in Eclipse. The project is a JERSEY REST backend with angularjs javascript frontend. I would like to know how to check what version of EclipseLink my project is using. Where can I find this property? I've searched high and low but I can't find it - I know that I did stumble across it before, so it definitely exists.... This question is trying to get to the bottom of the following question I posed months ago about a problem with

How to modify dependency for Jersey projects built on Gradle?

社会主义新天地 提交于 2019-12-12 02:16:48
问题 I was attempting to solve problems of MessageBodyWriter not found in a Jersey project I created. I got a lot of recommendations fixing the dependency, some of which mention changing pom.xml, but since the project I got was built and compiled in Gradle, there are not similar xml like that. What are the similar files I need to look into in terms of checking dependency? 回答1: Maven → Gradle == <groupId>:<artifactId>:<version> So <dependency> <groupId>org.glassfish.jersey.media</groupId>