jersey

Jersey @PathParam : contains multiple parameters with no annotation

放肆的年华 提交于 2019-12-11 07:59:53
问题 The following is my method signature which I am using in Jersey , when I debug/run the program I am getting error as : [[FATAL] Method public javax.ws.rs.core.Response com.xxxx.xxxxx.Xxxxx.xxxxx.xxxxxxxx(java.lang.String,java.lang.String,java.lang.String,javax.ws.rs.container.ContainerRequestContext) on resource class com.xxxxxx.xxxxx.xxxxxx.xxxxxx contains multiple parameters with no annotation. My code: @PUT @Path("/user/{user}/{role}") @Consumes({MediaType.APPLICATION_JSON,MediaType.TEXT

Exception while accessing Jersey REST webservice

送分小仙女□ 提交于 2019-12-11 07:59:15
问题 I am trying to get REST webservices working in my app. I am using jersey with Spring 2.5. The endpoints for the webservices are generated with enunciate 1.9. When I deploy the generated war file with Tomcat and access the REST webservice I get the following exception: javax.servlet.ServletException: Servlet.init() for servlet jersey threw exception org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter

Unable to make JDBC Connection

偶尔善良 提交于 2019-12-11 07:55:45
问题 I am creating web API project using Jersey and Hibernate. When I tried yesterday all worked well. Today it started showing "Unable to make JDBC connection" error. I tried all possible ways to check it. Still I am not able to resolve it. Any help would be highly appreciated. I am creating the session as follows: SessionFactory sessionFactory; ServiceRegistry serviceRegistry; Configuration configuration = new Configuration(); configuration.configure("hibernate.cfg.xml"); serviceRegistry = new

REST: convert XML content passed with POST to a java object, attribute inside the element

霸气de小男生 提交于 2019-12-11 07:51:26
问题 I am working with REST services and i want to pass an XML-text with a POST request. My server is implemented in JAVA. Let's say that i am sending this XML: <range> <higher value="3"></higher> <lower value="2"></lower> </range> As i understand (correct me if i am wrong), the easiest way to convert the XML in the request to a java object, is to define a class with the proper annotations. For example: @XmlRootElement(name = "range") public class RangeClass { @XmlElement (name = "lower") private

Multiple files upload in a REST service using Jersey

点点圈 提交于 2019-12-11 07:45:50
问题 Quite a few links here that suggest using multipart/form-data and how to get the file upload here. Couldn't really find one for a combination of multiple files uploaded via CURL command and to a REST service accepting FormDataMultiPart . The code in service currently looks like : @javax.ws.rs.POST @javax.ws.rs.Path("/sample-bulk") @javax.ws.rs.Consumes(javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA) public javax.ws.rs.core.Response bulkUpload(@FormDataParam("file") org.glassfish.jersey.media

Enabling Jersey trace logging causes MaxHeaderCountExceededException

心已入冬 提交于 2019-12-11 06:58:40
问题 I am trying to debug my jersey 2 app on Payara 162, but on every request, after the trace information is printed I get this exception and the client gets no response: org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException: Illegal attempt to exceed the configured maximum number of headers: 100 at org.glassfish.grizzly.http.util.MimeHeaders.createHeader(MimeHeaders.java:396) at org.glassfish.grizzly.http.util.MimeHeaders.addValue(MimeHeaders.java:422) at org.glassfish

Jersy 2 Client + JAXB (MessageBodyWriter not found)

大城市里の小女人 提交于 2019-12-11 06:57:14
问题 I'm trying to use Jersy 2 in client mode to post XML to a server but i always get an exception. I have got only one dependency in my pom file: <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.18</version> </dependency> My Java code: public static void main(String... args) { Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8080"); Entity<SimpleClass> entity = Entity.entity(new SimpleClass(),

MessageBodyReader/Writer for Generic class

最后都变了- 提交于 2019-12-11 06:53:26
问题 I have a class public class Tree<T> { private T value; private Tree<T> parent; private List<Tree<T>> children; ... } I then want to make a MessageBodyReader and Writer to be able to produce and consume JSON that represent instances of this class, but without circular references. So a JSON document would exclude the parent. I then get a method I shall implement that looks like this @Override public Tree<?> readFrom(Class<Tree<?>> type, Type genericType, Annotation[] annotations, MediaType

Add a newline to swagger output

限于喜欢 提交于 2019-12-11 06:50:09
问题 I am using swagger-jersey2-jaxrs version 1.5.15 . I am on swagger-ui 3.0.9 . I added a description to a header using @SwaggerDefinition annotation and tags (as the description parameter is now deprecated). The code goes like: @Api(tags = { "Hello World" }) @SwaggerDefinition(tags = { @Tag(name = "Hello World", description = "Description about world: " + " \n" + "1. Hello " + "\n" + "2. World " + "<br>" )}) By using this, I was able to add a description to the "Hello World" header. My question

How to use Jackson ObjectMapper to convert to Pojo for multiple data

大兔子大兔子 提交于 2019-12-11 06:45:53
问题 I would like to convert the following string/ JSONObject to POJO, {"list":["\r\n{\r\n\"id\":\"1\",\r\n\"protocol\":\"udp\",\r\n\"srcPorts= \":\"3000-4000 \",\r\n\"destPorts\":\"1790-2000\"\r\n}","\r\n{\r\n\"id\":\"2\",\r\n \"protocol\":\"tcp\",\r\n\"srcPorts\":\"3000-4000\",\r\n\"destPorts\":\"1790-2000 \"\r\n}"],"user":"\r\n{\r\n\"name\":\"John\",\r\n\"address\":\"x.x.x.x\",\r\n\"email \":\"john@p.com\"\r\n}"} How do I convert to Pojo using Jackson ObjectMapper. The 2 Pojo classes are as