jersey

Jersey : Is it possible to specify multiple values in @DefaultValue() annotation

丶灬走出姿态 提交于 2019-12-20 03:28:12
问题 I am playing around with Java API for RESTful Web Services (JAX-RS) , and encountered @DefaultValue annotation in Jersey implementation of JAX-RS. Here is the code snippet @GET @Path("/query") public Response getUserWithQueryParams( @DefaultValue("defaultId") @QueryParam("from")String from, @DefaultValue("defaultName") @QueryParam("to") String to, @DefaultValue("mobileNo")@QueryParam("orderBy") List<String> orderBy ){ My third argument is of List<String> which can have multiple values for

How to catch JsonParseException from REST endpoint

限于喜欢 提交于 2019-12-20 03:22:10
问题 I have an endpoint like this: @POST public Response update(MyDocument myDocument){} If the request is not valid, my server would get some quite long logs like this: javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.fasterxml.jackson.core.JsonParseException: Unexpected character.... ... Caused by... ... Caused by... The exception is hard to be avoided completely, so I am wondering how could I catch the JsonParseException? 回答1: Implement an ExceptionMapper for

Jersey and HK2 - Injecting current user

戏子无情 提交于 2019-12-20 03:19:27
问题 I'm working with jersey 2.17 and HK2 to create a simple rest app. I have a ContainerRequestFilter that rejects any request that doesn't have the "currentuser" cookie. I have something like this: @Path("/users") public class UserResource { private UserService userService; @GET @Path("/orders") @Produces("application/json") public List<Order> findOrdersOfCurrentUser() { // some ugly code to access headers, extract cookies, and finally // extract username (a String) from a particular cookie

Caused by: java.net.NoRouteToHostException: No route to host

拈花ヽ惹草 提交于 2019-12-20 03:00:21
问题 I am trying to deploy my Jersey project from eclipse on openshift and I am getting this error in the tail files Caused by: java.net.NoRouteToHostException: No route to host before when I had like this: String host = "jdbc:mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/bustrackerserver" I got this error: 'java.lang.NumberFormatException: For input string: “OPENSHIFT_MYSQL_DB_PORT”' I have pinged this ip address 127.10.230.440 and I am getting response I checked whether some of the

JBoss Wildfly with Jersey Web Services Deployment Error JBAS011859: Naming context is read-only

痞子三分冷 提交于 2019-12-20 02:35:14
问题 Im working on a Java Webservices Project Using the Jersey Servlet (1.18.1). When deploying my EAR file to Jboss WildFly (8.1.0) I'm Getting the following Error and im unsure why its breaking as this same EAR file deployed and worked 100% in JBoss7 (7.1.1). The Error stacktrace: java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:126) at org.jboss.as.naming

JBoss Wildfly with Jersey Web Services Deployment Error JBAS011859: Naming context is read-only

风流意气都作罢 提交于 2019-12-20 02:35:02
问题 Im working on a Java Webservices Project Using the Jersey Servlet (1.18.1). When deploying my EAR file to Jboss WildFly (8.1.0) I'm Getting the following Error and im unsure why its breaking as this same EAR file deployed and worked 100% in JBoss7 (7.1.1). The Error stacktrace: java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:126) at org.jboss.as.naming

NoSuchMethodError when accessing web app resource on Tomcat server

别来无恙 提交于 2019-12-20 02:33:07
问题 After searching online this is a question I have been unable to find an answer for. My Web Application is deployed to the tomcat server i know this is all working as the index.jsp displays the text. but when i try to access the resource i have made that should print out hello world the tomcat server returns this message java.lang.NoSuchMethodError: com.sun.jersey.core.spi.component.ProviderServices.<init>(Lcom/sun/jersey/core/spi/factory/InjectableProviderFactory;Lcom/sun/jersey/core/spi

basic authentication fails with glassfish

Deadly 提交于 2019-12-20 02:30:02
问题 First of all, my apologies for this long post. This is a continuation of my previous question (Authentication required window popping up after 7u21 update) regarding this issue, but I narrowed down the search. In short, it seems that my BASIC authentication is broken since Java 7u21. Applets started through JNLP files are not functioning stable at all and gives Authentication Popup windows. THE SETUP First of all I've set up a MySQL database with a usertable and grouptable. Table:

Jersey REST Client: How to add XML file to the body of POST request?

守給你的承諾、 提交于 2019-12-20 02:29:32
问题 My code so far: FileReader fileReader = new FileReader("filename.xml"); Client c = Client.create(); WebResource webResource = c.resource("http://localhost:8080/api/resource"); webResource.type("application/xml"); I want to send contents of filename.xml with POST method but I have no idea how to add them to the body of request. I need help as in the net I was only able to find how to add Form args. Thanks in advance. 回答1: You can always use the java.net APIs in Java SE: URL url = new URL("http

Use Jackson as JAXB-JSON-processor in JavaEE Application

天涯浪子 提交于 2019-12-20 02:27:27
问题 I've seen many articles and SO-questions about this - but I just don't get it working. My goal is to use Jackson as JSON processor in a JavaEE application. What do I have so far? pom.xml either this one <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>2.17</version> </dependency> or this one (which of them is correct in the end?) <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json