jax-rs

How to post json object from ajax to java class without without servlet but with JAX-RS?

倖福魔咒の 提交于 2020-01-14 03:34:10
问题 I am new to JAX-RS , I am trying to learn new things about it. I am stuck with one issue regarding, creating a JSON object in Java Script , posting it through ajax to a Java class using JAX-RS and annotations and creating a JSON file out of it. I am creating a Maven project for it. Can anyone please suggest me any tutorial for this. I am trying to implement it from past 1 week but unable to do anything. Any suggestions appreciated. My POST annotation in Java is: @POST @Path("/post") @Consumes

JAX-RS Response Object displaying Object fields as NULL values

元气小坏坏 提交于 2020-01-13 10:06:33
问题 First time implementing JAX-RS Client API in an application and I am having some small problems when it comes to storing the response data, which is returned as JSON as a Java BEAN. Refer to the following code snippets below which demonstrate how I have implemented it thus far. object = client.target(uri).request().post(Entity.entity(requestObject, APPLICATION_JSON), Object.class); Essentially, I would like to store the returned JSON response from the web service into my Java BEAN, which in

Does Weblogic12c support jersey 2.x?

橙三吉。 提交于 2020-01-13 05:41:47
问题 I have upgraded my web application to JAX-RS 2.0. The web application seems to work fine on Apache Tomcat. However, it does not get deployed on Weblogic 12c (or even 10.3.6). I am not sure if there is a proper support by weblogic and I believe it requires some configuration and class loader filtering to override the default JAX-RS 1.1 implementation ? Any idea how to achieve this and make my web application run on WLS 12c ? 回答1: WebLogic 12c is Java EE 6 certified and so, implements JAX-RS 1

Can Swagger JaxRS do ApiModel Inheritance with discriminator?

荒凉一梦 提交于 2020-01-13 02:30:35
问题 I've tried with the Swagger JaxRs current master 1.0, and the devel_2.0 branch for Swagger 2.0. @ApiModel(value = "Animal", subTypes = {Dog.class, Lion.class}, discriminator = "type") public class Animal { @ApiModelProperty(value = "the discriminator field.") private String type; And here is one of the sub classes, @ApiModel(value = "Lion", parent = Animal.class) public class Lion { @ApiModelProperty(value = "the discriminator field.") private String type; I haven't found any many examples of

SecurityContext doesn't work with @RolesAllowed

匆匆过客 提交于 2020-01-12 19:13:09
问题 I'm currently creating a backend server using Jersey 2.5.1 in a Tomcat 7. For the security I'm using the @RolesAllowed , @PermitAll etc. annotations, and I have created my custom ContainerRequestFilter and SecurityContext . My problem is that when my @RolesAllowed annotated resource is requested it always denies permission, even if I force my isUserInRole(role) method to return true . However, my filter method gets called. Do you have any suggestions? I'll paste some relevant code below. My

JEE6 REST Service @AroundInvoke Interceptor is injecting a null HttpServletRequest object

折月煮酒 提交于 2020-01-12 07:54:05
问题 I have an @AroundInvoke REST Web Service interceptor that I would like to use for logging common data such as the class and method, the remote IP address and the response time. Getting the class and method name is simple using the InvocationContext, and the remote IP is available via the HttpServletRequest, as long as the Rest Service being intercepted includes a @Context HttpServletRequest in its parameter list. However some REST methods do not have a HttpServletRequest in their parameters,

Multiple JAX-RS applications in the same WAR

蓝咒 提交于 2020-01-12 05:41:25
问题 I have @ApplicationPath("/resourcesP") public class RestfulPrediction extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> set = new HashSet<Class<?>>(); set.add(PredictionsRS.class); return set; } } And @ApplicationPath("/resourcesA") public class RestfulAdage extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> set = new HashSet<Class<?>>(); set.add(Adages.class); return set; } } Two different ApplicationPath and the class are as

How to deal with accept-parameters when developing a jax-rs application

一世执手 提交于 2020-01-12 03:35:07
问题 In order to deal with different versions of a content-type i am trying to use the accept-parameters of the "Accept*" headers (RFC 2616). Accept: application/vnd.mycompany.mytype;version=2 , application/vnd.mycompany.mytype;version=1;q=0.1 The problem is that Jax-RS annotations do not support Accept-parameters... @GET @Produces("application/vnd.test;version=1") public Response test1() { return Response.ok("Version 1", "application/vnd.test").build(); } @GET @Produces("application/vnd.test

How do I get the JAX-RS @Path of a different resource during a POST?

早过忘川 提交于 2020-01-11 19:50:29
问题 I have two REST classes for a simple web service (Jersey and GlassFish) that involves user resources - one to operate on all users (e.g., a factory for @POSTing) and another on individual users (e.g., @GET, @PUT, @DELETE). They are at: @Stateless @Path("users") public class AllUsersResource {...} @Stateless @Path("user") public class OneUserResource {...} respectively. When POSTing to AllUsersResource I want to return the Location (via Response.created(uri).build() ) of the new User, e.g.,

JAX-RS failed to inject @EJB or @Inject

偶尔善良 提交于 2020-01-11 09:20:54
问题 I'm trying to test a minimal JAX-RS + EJB/CDI injection mechanism and currently hitting a road-block due to GlassFish unable to inject for whatever reason. (Using @Inject will throw NPE because GlassFish cannot inject the POJO). My beans.xml contains only <beans /> Here's my web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun