jersey

Jersey HK2 Dependency Injection doesn't work after update to v2.27

泪湿孤枕 提交于 2019-12-23 02:53:29
问题 I have a project using Jersey v2.25.1. I was using Jersey's inbuilt HK2 injection to perform dependency injection, and everything worked fine. Fast forward to now, I decided to update to Jersey v2.27. When I ran my project, I got the following exception: java.lang.IllegalStateException: InjectionManagerFactory not found After some googling, I found that I needed to add the jersey-hk2 dependency. Doing so made me get the following exception: org.glassfish.hk2.api.UnsatisfiedDependencyException

HTTP Status 403 - Invalid CSRF Token '9ee6949c-c5dc-4d4b-9d55-46b75abc2994' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'

孤街醉人 提交于 2019-12-23 02:42:13
问题 I am developing a web application which has a front-end with angularjs and a back-end with spring-security and jersey. I am trying to implement spring-security. I can authenticate the user. But I stucked at the logout point. I am sending the X-CSRF-TOKEN within a value, but it seems that spring-security is refusing it. web.xml <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>M2Carros</display

Drop-wizard request response logging

懵懂的女人 提交于 2019-12-23 01:57:39
问题 I want to log each request and response in dropwizard into different files. For example I want all the requests to be logged in /var/log/applicationname-request.log and all responses into /var/log/applicationname-response.log Is there any way in which we can achieve the same? 回答1: Unfortunately DropWizard currently doesn't support this natively. See this lively discussion for more information. Fortunately there's a workaround if you're willing to forego configuring logging with DropWizard all

Securing with roles annotations not working (Jersey)

自古美人都是妖i 提交于 2019-12-23 01:34:21
问题 I'm new here even though I've found many answers to my problems in here before. Now I'm looking for help with this: I have this little example resource on my little REST API: @Path("/greeting") @PermitAll public class HelloResource { @GET @Produces(MediaType.TEXT_PLAIN) @Path("all") public String sayHelloToAll() { return "Hello, everybody!"; } @GET @Produces(MediaType.TEXT_PLAIN) @RolesAllowed("admin") @Path("admin") public String sayHelloToAdmin() { return "Hello, admin!"; } } In order to

GCM: java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender

若如初见. 提交于 2019-12-22 23:24:19
问题 I have been trying to get Google Cloud Messaging to work in eclipse. I was able to compile the example given on their demo webpage and run that without any errors; however, when I try to create my own example using jersey I get the run time error "java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender" when the following code tries to create a sender. @POST @Path("/send") public Response sendMessage() throws IOException { Sender sender = new Sender("api_key"); Message message =

GCM: java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender

故事扮演 提交于 2019-12-22 23:23:18
问题 I have been trying to get Google Cloud Messaging to work in eclipse. I was able to compile the example given on their demo webpage and run that without any errors; however, when I try to create my own example using jersey I get the run time error "java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender" when the following code tries to create a sender. @POST @Path("/send") public Response sendMessage() throws IOException { Sender sender = new Sender("api_key"); Message message =

Spring Boot REST API/Spring Security: Return custom message when authentication fails

佐手、 提交于 2019-12-22 17:19:15
问题 I have a Spring Boot app using Jersey as the JAX-RS implementation. This is my security configuration: @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) @EnableWebSecurity public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Autowired TokenAuthenticationProvider tokenAuthenticationProvider; @Override public void configure(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(tokenAuthenticationProvider); } @Override protected

Jersey - Obtain the contents of an OutputStream in an Interceptor before calling context.proceed()

♀尐吖头ヾ 提交于 2019-12-22 14:55:14
问题 Using an Interceptor in Jersey I can manipulate the Output, however, I also want to add a Header to the response which value is calculated from the result of the output. @Sha256Sum public class Sha256SumInterceptor implements WriterInterceptor { public static final String SHA256_HASH_HEADER_NAME = "SHA256-SUM"; @Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { // Retrieve the OutputStream, read the contents and calculate the

Initialize singleton in Java Jersey 2 JAX-RS

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 12:31:48
问题 I'm new to Jersey (2.22.2), so bear with me please. I am creating a REST service that interfaces with an LDAP server for storing, removing, and retrieving user data. The service acts as a security intermediary by performing encryption/decryption. There is quite a bit of initialization that must take place before the REST services can be utilized, and I would like to only perform this initialization once (when the application is deployed on the server). So this service would be run as a

Jersey @Produces Apache XSSFWorkbook

人盡茶涼 提交于 2019-12-22 12:14:09
问题 I am trying to produce a XSSFWorkbook using Jersey. I have tried the following headers and nothing seems to work: @Produces("application/xml") @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Produces("application/vnd.openxml" All return the following error: Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.apache.poi.xssf.usermodel.XSSFWorkbook, and Java type class org.apache.poi.xssf.usermodel.XSSFWorkbook, and MIME media