jersey

Jersey Client resulting in 415 Unsupported media type

柔情痞子 提交于 2019-12-11 14:04:00
问题 The obvious reason for this would be not providing proper content type. But I am providing. Still i am getting Unsupported Media Type. Not sure why. Any help greatly appreciated. Client c = Client.create(); WebResource resource = c.resource(HOST+"/test"); Gson gson = new Gson(); Test test = new Test(); test.setTestName("TEST AUTOMATION"); resource.header("Content-Type", "Application/json"); String testStr = gson.toJson(test); System.out.println("Request Str: "+testStr); ClientResponse

Getting a ClassNotFoundException using Eclipse, JBoss 7.1.1 and Jersey 1

早过忘川 提交于 2019-12-11 13:46:09
问题 I am developing a restful Web Service, but i'm getting this error: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer I know there are many topics with this kind of problem. I already checked them out and tried their solutions, but the error i am getting remains. Here's my pom.xml : <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi`enter code here`="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

How to send selected file list when submit button click in AngularJs

泪湿孤枕 提交于 2019-12-11 13:41:24
问题 I am using ng-file-upload to send files to server.ng-file-upload worked perfectly with upload file one by one.I am using latest chrome browser. Sample code snippet jsfiddle in there files are uploaded to the server when files are selected in the file input.But what i want is that files (selected file array) should be uploaded only to the server when submit button is clicked along with other form data. Jersey REST service @POST @Path("/manual") @Consumes(MediaType.MULTIPART_FORM_DATA)

JAX-RS (Jersey): String from JSON request body still escaped

自闭症网瘾萝莉.ら 提交于 2019-12-11 13:11:23
问题 This is driving me crazy. I'm working on a REST endpoint in JAX-RS (Glassfish / Jersey). I have a method that's supposed to receive a String, store it and return it. The entire endpoint should consume and produce JSON. But every time I post a String to the method, it's handed to me in escaped form. E.g. if I post: fetch("http://localhost:8080/myapp/rest/myresource", { method: "post", credentials: 'same-origin', body: JSON.stringify("test\ntest"), headers: { "Content-Type": "application/json"

How to test a Java RESTful web service with curl - problems with PUT verb

廉价感情. 提交于 2019-12-11 13:07:50
问题 I'm trying my first Java RESTful web service and probably I don't have clear some mechanisms. Here an example of my code: @Path(Paths.USERS) public class UserService { private static final String OK_MESSAGE_USERSERVICE_PUT = Messages.OK_MESSAGE_USERSERVICE_PUT; private Client esClient = ElasticSearch.getClient(); @GET @Produces(MediaType.APPLICATION_JSON) public String get(@QueryParam(QParams.ID) String id) { // TODO Authentication try { GetResponse response = esClient .prepareGet(PRIMARY

Authentication problem using Jersey and Glassfish

被刻印的时光 ゝ 提交于 2019-12-11 12:58:49
问题 I'm trying to configure Glassfish using the REST interface. I am using Jersey in my Java code. All works well, except authenticating. Bellow is a peace of code i use to do a GET. Whenever i have a used defined in Glassfish, this peace of code returns 401. I have checked the credentials using Glassfish Administration Console and CURL and they are valid. I suppose it is a problem in the way i am using Jersey. I have googled this, but i can not find relevant information. Does anyone have any

Restful WebServices in Java using Eclipse, Tomcat and Jersey

喜你入骨 提交于 2019-12-11 12:43:42
问题 How to create simple webserver in Java using Eclipse, Tomcat and Jersey i.e steps to follow? We are creating simple webserver using the below links: http://www.ibm.com/developerworks/web/library/wa-aj-tomcat/ http://www.vogella.de/articles/REST/article.html but we got an error like this: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer 回答1: Have maven running. Then run this command(press enter if it asks sth): mvn archetype:generate -DgroupId=com.test

Trying Spring Security with Jersey What is wrong with my security-context.xml file?

蹲街弑〆低调 提交于 2019-12-11 12:43:41
问题 I am trying to add Spring Security to my Jersey Webapp. I tried using the following as my security-context.xml file in addition with my existing applicationContext.xml (2 separate files for contextConfigLocation in web.xml): http://snipt.org/OIh based on a solution provided here: User authentication on a Jersey REST service However upon starting tomcat... I get the following error: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web

How to do server-side responses for multiple HTTP ranges in one response?

家住魔仙堡 提交于 2019-12-11 12:26:17
问题 I'm trying to find a good example of how HTTP ranges should be handled on the server side. I would like to be able to support multiple ranges. Could somebody please show me an example, or provide some useful links? I've read the RFC, but I'm still a bit confused regarding the multipart stuff. 来源: https://stackoverflow.com/questions/31070137/how-to-do-server-side-responses-for-multiple-http-ranges-in-one-response

Two Exception Mappers in Dropwizard

笑着哭i 提交于 2019-12-11 12:23:42
问题 I have parent pom with Dropwizard service. In that service I have some exception mapper declaration, for example: @Provider class ExceptionMapperForClassA {...} Now in my child pom I'm extending this parent service and I want to create New Exception mapper for ClassA and I would like to extend it from ExceptionMapperForClassA . I couldn't find any information in Jersey doc, which describes behaviour of Jersey when two exception mappers for same class are declared. https://jersey.java.net