jersey-2.0

Customise oath2 token request to accept extra data

旧街凉风 提交于 2019-11-27 03:35:40
问题 I am using jersey and spring-oauth2 with spring security. My app is working fine with end points "/oauth/token". I want to change the endpoints to accept more data. The requirement is, I want to send more details to the token API (i.e. the device details OS, phone/tablet/web etc.). So, I want to override the endpoint and if authentication is successful, I want to store that extra information in database. I could not find anything related to changing the API in such a way. Can someone help?

Using default Providers/MessageBodyWriters in Jersey 2

♀尐吖头ヾ 提交于 2019-11-27 03:24:33
问题 Just starting with Jersey, I've been trying to reproduce the simple example in the latest Jersey documentation 'building responses'. This part, as far as I understand, should show how Response and ResponseBuilder can be used to easily return a response in combination with Entity<T> for response content. Now, the documentation states that several data types are by default supported (here: 'Representations and Java types'). String prime among them, matching any media type. Of all the variations

Migrate Jersey project to use Java 10 results in java.lang.IllegalArgumentException at jersey.repackaged.org.objectweb.asm.ClassReader.<init>

为君一笑 提交于 2019-11-27 03:22:29
问题 Previously project is on Tomcat 8 and JDK 8 it was Working Fine But when i migrated my project on Tomcat 9 and JDK 10 it is giving me error as follows : Oct 05, 2018 11:02:01 AM org.apache.catalina.core.ApplicationContext log SEVERE: StandardWrapper.Throwable java.lang.IllegalArgumentException at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170) at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153) at jersey.repackaged.org.objectweb.asm

How do I properly configure an EntityManager in a jersey / hk2 application?

随声附和 提交于 2019-11-27 02:10:30
I have a jersey-2 / hk2 application which uses JPA persistence. The EntityManager is bound at startup like this public MyApplication() { // ... register(new AbstractBinder() { @Override public void configure() { bindFactory(EmFactory.class) .to(EntityManager.class) .in(RequestScoped.class); } }); } with the factory class being public class EmFactory implements Factory<EntityManager> { private static final String PERSISTENCE_UNIT = "unit"; private EntityManagerFactory emf; private CloseableService closeableService; @Inject public EmFactory(@Named(PERSISTENCE_UNIT) String persistenceUnit,

How to add a http proxy for Jersey2 Client

为君一笑 提交于 2019-11-27 02:09:55
问题 It's easy to set a proxy for client on Jersey1.x: config.getProperties().put(ApacheHttpClientConfig.PROPERTY_PROXY_URI, proxyUrl); But how to add a http proxy for Jersey2.x client? I checked the source code and didn't find the implementation does that in: org.glassfish.jersey.client.HttpUrlConnector Thanks! 回答1: thanks @feuyeux, the solution is work for me, ps, the code below is works in the proxy with http basic auth: ClientConfig config = new ClientConfig(); config.connectorProvider(new

Listing all deployed rest endpoints (spring-boot, jersey)

邮差的信 提交于 2019-11-27 01:02:59
Is it possible to list all my configured rest-endpoints with spring boot? The actuator lists all existing paths on startup, I want something similar for my custom services, so I can check on startup if all paths are configured correctly and use this info for client calls. How do I do this? I use @Path / @GET annotations on my service beans and register them via ResourceConfig#registerClasses . Is there a way to query the Config for all Paths? Update: I register the REST Controllers via @Bean public ResourceConfig resourceConfig() { return new ResourceConfig() { { register(MyRestController

Using Spring property placeholders with Jersey @Path and @ApplicationPath

南笙酒味 提交于 2019-11-26 23:23:39
问题 I use Jersey and Spring in my project. 'jersey-spring3' is used for integration between them. I would like to make my resource classes more flexible and use properties inside @Path annotations, like: @Path("${some.property}/abc/def") But Spring can't inject some.property to Jersey's annotations @Path and @ApplicationPath . Is there any way to have some configurable (using property files) value inside @Path value of Jersey's resource? (I realize that it would be easier to replace Jersey by

Spring-Jersey : How to return static content?

a 夏天 提交于 2019-11-26 22:25:44
问题 Question : How do I expose my css/ , images/ , js/ and other static files? How do I return a JSP page in my controller (not a String method) for my index view? Problems : In efforts to solve question #1 other projects use a filter jersey.config.servlet.filter.staticContentRegex (as seen here Stackoverflow Question) I haven't been able to find dependencies that work correctly/at all with my project setup. In efforts to solve question #2 I attempted to introduce dependencies to use Viewable .

Jersey stopped working with InjectionManagerFactory not found

独自空忆成欢 提交于 2019-11-26 21:59:50
I am receiving below error while running my Jersey API in Tomcat 8.5.11 which is causing my API to stop: HTTP Status 500 - Servlet.init() for servlet Jersey REST Service threw exception type Exception report message Servlet.init() for servlet Jersey REST Service threw exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet.init() for servlet Jersey REST Service threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) org.apache.catalina.valves

How to in-memory unit test Spring-Jersey

戏子无情 提交于 2019-11-26 20:31:59
I'm working with Spring-Jersey3 and cannot figure out how to unit test the RESTFul API with Spring beans Controller package com.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.service.DataSource; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("test") @Component public class SpringController { @Autowired private DataSource datasource; @GET @Produces(MediaType.TEXT_PLAIN) public String getHello() { return new String(datasource.load()); } }