jersey-2.0

Guice nullpointer exception on injected instance

六眼飞鱼酱① 提交于 2019-12-10 18:46:51
问题 I'm using Guice in Jersey2 for DI (i want to use it so i can use Google App Engine -> not working with HK2). My ApplicationResource: public class ApplicationResource extends ResourceConfig { private static final Logger LOGGER = null; public ApplicationResource() { System.out.println("Application startup"); // Register resources and providers using package-scanning. packages("com.crawler.c_api"); // Register my custom provider - not needed if it's in my.package. register(ResponseCorsFilter

Trouble Autowiring Spring Dependencies In Jersey Using Jersey-Spring

末鹿安然 提交于 2019-12-10 18:32:35
问题 I'm attempting to get DI setup in my Jersey application using Jersey-Spring. However when I hit a route I'm getting 500 errors and see the stack trace below: No beans found. Resolution failed for type class com.roommateAPI.service.HelloWorldService. /RoommateAPI/hello/two java.lang.NullPointerException at com.roommateAPI.resources.HelloWorldResource.helloWorldTwo(HelloWorldResource.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl

What is the moxy equivalent to Jackson's JsonAnySetter?

别说谁变了你拦得住时间么 提交于 2019-12-10 18:26:20
问题 I'm attempting to move to Jersey 2.0. Which is giving me pains with Jackson, and the docs recommend using Moxy. I got Moxy working for get and post calls where everything matches nicely however I have a need to deal with possible unknown elements. // Handle unknown deserialization parameters @JsonAnySetter protected void handleUnknown(String key, Object value) { if (unknownParameters == null) { unknownParameters = new HashMap<>(); } unknownParameters.put(key, value); } This worked well with

Spring Boot 2 Actuator endpoints inaccessible with Jersey

南笙酒味 提交于 2019-12-10 18:21:29
问题 I have a very simple demo application using the Spring Boot 2.0.x.RELEASE In my POM I have: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud

Glassfish 4.1 - Latest Jersey version

浪子不回头ぞ 提交于 2019-12-10 18:21:28
问题 We want to integrate latest Jersey Version in Glassfish 4.1. Glassfish provides Jersey 2.21.0 implementations, so we added Jersey 2.22.2 to WEB-INF/lib. It seams to work with new version. But is this the correct solution? Will Glassfish always put the libraries in WEB-INF before its own to the classpath? 回答1: If it is not an option to modify glassfish installation, you still may force glassfish to consider the libs in your web app before the global ones. You just need to provide file

Why my request entity InputStream is always empty in ContainerRequestFilter (Spring+Jersey)

Deadly 提交于 2019-12-10 17:37:38
问题 I'm totally unable to get the Request payload/form in a JaxRS ContainerRequestFilter. My setup : JDK 8 SpringBoot 1.3.0.RELEASE Jersey 2.22.1 (from SpringBoot) here's my pom : (from Spring Initialzr) <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId

How to get HK2 ServiceLocator in a Jersey2 ServletContainer?

人走茶凉 提交于 2019-12-10 16:46:46
问题 I'd like to get Jersey2 and Guice to cooperate together, which is apparently rather difficult. I've seen some solution to this involving using the HK2-to-Guice bridge. But the bridge rely on getting the HK2 ServiceLocator instance in the init() of a custom Jersey2 ServletContainer in order to initialize GuiceBrige : public class MyServletContainer extends ServletContainer { @Override public void init() { ServiceLocator sloc = getApplicationHandler().getServiceLocator(); ... } } But somehow in

jersey multiparty returns NoClassDefFoundError: org/glassfish/jersey/internal/inject/ExtractorException [duplicate]

自作多情 提交于 2019-12-10 16:14:56
问题 This question already has answers here : java.lang.NoClassDefFoundError: org/glassfish/jersey/internal/inject/Binder when started Tomcat Server (2 answers) Closed 2 years ago . i am trying to create an api that consumes/uploads an image file i have configured my app like this: ResourceConfig file @ApplicationPath("api") public class appConfig extends ResourceConfig { public appConfig() { // Register resources and providers using package-scanning. packages("src.main.java.org.vaad.vaadAPI");

How to valid incoming JSON and check for missing properties? [Jackson,Jersey]

瘦欲@ 提交于 2019-12-10 16:12:56
问题 I'm using Jackson 2.7.0. and latest Jersey for JSON on REST API that handles DB communication with Hibernate 5+. I don't know how to verify incoming JSON if there are any missing properties in it. It is impossible to perform checking on primitive type if they are null. But also i would like to use primitive types because of performance hit. What is best practice to handle such problem? When I receive JSON like below, everything is ok: {"vehicle":{"id":1},"distance":1000,"quantity":2000} But

Cannot have JSP page load with Jersey server

半腔热情 提交于 2019-12-10 15:40:00
问题 I am using jersey 2.4 for my web service and cannot have the home page load the index.jsp. I made a IndexService POJO to try loading it from there too, but that doesn't work. I would like to just use the home page, instead of the having an IndexService POJO. The POJO is reached but returns this: HTTP Status 500 - org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=text/html, type=class org.glassfish.jersey.server.mvc.Viewable,