jersey-2.0

Custom MOXyJsonProvider in Jersey 2 not working?

一曲冷凌霜 提交于 2019-12-04 09:52:30
I was reading over the answer for Moxy ignore invalid fields in json and the approach matched something I'm trying to do, so I decided to give it a shot.. I created a feature to disable the default ConfigurableMoxyJsonProvider; @Provider public class JsonFeature implements Feature { @Override public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase(); context.property(disableMoxy, true); return true; } } And I created a really simple custom provider;

Spring boot Jersey with groovy/gradle fails on startup

对着背影说爱祢 提交于 2019-12-04 06:16:03
问题 We're just starting a new project, and are looking into spring-boot for kickstarting our development. spring-boot seems powerful, but there's some magic going on that we yet don't understand. I've cloned the spring-boot samples and ran the Jersey Example. So far so good. I then converted this to Groovy/Gradle. relevant sections of the build script looks like this . . buildscript { repositories { jcenter() // maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io

Jersey returns 500 when trying to return an XML response

北城以北 提交于 2019-12-04 04:55:16
问题 I'm trying to create my own RESTful WS application using Jersey 2.12 based from this article. I want to return an XML representation of a class depending on the id been passed from the url, however, I'm getting a 500 response code when trying from either Advanced Rest Client Application (google chrome app) or browser. Below are the details: web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"

Java Restful Service eclipse tomcat HTTP Error 404

穿精又带淫゛_ 提交于 2019-12-04 04:37:19
问题 i try to keep up with a java rest service. So i found some tutorials, which explain always the same way. But i cant get this running :(. I made Dynamic Web Project in Version 2.5 and Tomcat 7.0 in eclipse. Then i load following jars to WEB-INF/lib My Projectname is com.freespots.rest. I created following web.xml Ok now iam going to create the java-class right? Well i did it Java Resources/src/com.freespots.rest.service: If i start Tomcat and type url to my browser like localhost:8080/com

How do I get a reference to the Jackson Object Mapper in a jersey2 / hk2 application

痞子三分冷 提交于 2019-12-04 03:49:28
I have a jersey2 application configured for JSON support via Jackson, adding <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>${jersey.version}</version> </dependency> in the POM file and public MyApplication() { ... register(JacksonFeature.class) ... } in my application. Everything works, my resources get deserialized POJOs as arguments @POST @Consumes(MediaType.APPLICATION_JSON) public void blah(MyPojo p) { ... } Now one of thoese resources needs a reference to Jackson's ObjectMapper to do some deserialization on its own.

Jersey 2.x Security context does not work?

丶灬走出姿态 提交于 2019-12-04 03:45:19
问题 While i am trying to create java jersey application authentication roles does not work for me. Java code :- package org.student.resource; import javax.annotation.security.PermitAll; import javax.annotation.security.RolesAllowed; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ext.Provider; @Path("/resource") @PermitAll public class Resource { @GET public String get(){ return "GET"; } @RolesAllowed("admin") @POST public String post(){ return "Post

NoClassDefFoundError ProcessingException while migrating from jersey 1.x to jersey 2.x ( 2.8 )

旧街凉风 提交于 2019-12-04 03:33:10
问题 I developed a web service application which was working fine with jersey 1.x ( 1.16 ) I recently tried to migrate to latest stable jersey version 2.8 I deleted all jersey jar files of v1.16 then I downloaded jersey jars of v2.8 from the link - https://jersey.java.net/download.html As per documentation I came to know that, I should have latest servlet jar, servlet jar 2.5 or above, So I downloaded servlet-api-2.5.jar and added the same to /libs folder. I downloaded javax.ws.rs-api-2.0-m09.jar

Jersey jax.rs client 2.5 follow redirect from HTTP to HTTPS

筅森魡賤 提交于 2019-12-04 02:56:16
问题 I have a setup where tomcat server hosting my REST servers redirects calls from HTTP (port 9080) to HTTPS ( port 9443 ). I'm using jersey 2.5 implementation and cannot manage to configure the clients to follow redirections. I've found this SO question( Jersey client doesn't follow redirects ), however it's provided for jersey 1.X series and the API has changed. I've tried to adapt it for 2.5 with the following test code : SSLContextProvider ssl = new TrustAllSSLContextImpl(); // just trust

Getting a whole lot of “scanned from multiple locations” warnings in simple Jersey web app

血红的双手。 提交于 2019-12-04 02:44:36
Getting back to Java after some time, and I'm trying to get a simple RESTful API going on with Java 8, Jersey 2.27 and Jetty 9.4.9 using the command line. The app does work , but I keep getting hundreds of warnings like: 2018-04-27 01:17:24.845:WARN:oeja.AnnotationParser:main: Unrecognized runtime asm version, assuming 393216 2018-04-27 01:17:24.945:WARN:oeja.AnnotationParser:qtp988458918-12: javax.el.ArrayELResolver scanned from multiple locations: jar:file:///tmp/jetty-0.0.0.0-8081-paste4j.war-_-any-8355640322316327743.dir/webapp/WEB-INF/lib/el-api-2.2.jar!/javax/el/ArrayELResolver.class,

Jersey 2.0 “Getting Started” guide, mainClass not found

浪尽此生 提交于 2019-12-04 02:18:36
Hi I am trying to follow the Getting Started guide for Jersey 2.0. I did steps 1.1 and 1.2 as is. No problem there. For step 1.3 I had a problem cause maven could not find the javax-annotation 1.2 but I solved it following the advice of another Stackoverflow user and added a repository to my pom. So mvn clean test passes with no problems, BUT when I try to run mvn clean exec:java I get back [WARNING] java.lang.ClassNotFoundException: com.example.Main at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security