jersey

Jersey error JAXBStringReaderProviders$RootElementProvider

霸气de小男生 提交于 2019-12-06 04:47:15
问题 17-53-2014 12:53:31.817 INFO - Registering com.citronium.fizionomizm.service.server.controllers.Root as a root resource class 17-53-2014 12:53:31.820 INFO - Registering com.citronium.fizionomizm.service.server.controllers.RecognizePath as a root resource class 17-53-2014 12:53:31.822 INFO - Initiating Jersey application, version 'Jersey: 1.18 11/22/2013 03:05 AM' 17-53-2014 12:53:31.929 ERROR - The provider class, class com.sun.jersey.server.impl.model.parameter.multivalued

JAX-RS jersey ExceptionMapper: How to know the method who threw the exception

守給你的承諾、 提交于 2019-12-06 04:43:25
Im using JAX-RS jersey ExceptionMapper, and I'm wondering if there is a way to know inside the method toResponse(), which method (from the API) threw the exception. Example (dummy code) @javax.ws.rs.Path(“/bookstore/books/{bookID}”) public class Book { @javax.ws.rs.GET public String informationMethod(String user) { ... throw new Exception("Error"); .... } } @Provider public class SomeMapper implements ExceptionMapper<Exception> { @Override public Response toResponse(Exception ex) { //a way to get the method name that threw the exception. //In the above example is: informationMethod. String

Overriding included provider in Jersey

懵懂的女人 提交于 2019-12-06 04:38:47
问题 I need to make a custom ExceptionMapper in Jersey to handle the JsonProcessingException returned by Jackson. The Jackson library already includes ExceptionMapper providers for this exception in the form of JsonMappingExceptionMapper.java and JsonParseExceptionMapper.java (link). If I add a new provider for this exception mapper in "my.package" I get unpredictable results regarding the selected provider. Sometimes it will select the provider in "my.package" and sometimes it will select the

getting Invalid byte tag in constant pool : 19

老子叫甜甜 提交于 2019-12-06 04:34:25
i am creating one webservice and getting error like org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19. i am using tomcat 8.0 and java versoin is 1.8.0.152. A constant pool entry with tag type 19 is a module descriptor; see JVM spec table 4.4-A . I think you have attempted to use BCEL on a class compiled with a Java 9 (or later) compiler: The BCEL version you are using doesn't understand the tag. The class wouldn't load in a Java 8 JVM anyway. Modules were only introduced in Java 9, and the class file's major version number should be too recent

Exception Handling/Mapping for a particular class

末鹿安然 提交于 2019-12-06 04:21:11
I have resource class which itself's talks with a internal service. This resource acts a rest API for the service. The service layer can throw unexpected exceptions, thus the resource should handle those handled unexpected exceptions and log it. I am using dropwizard framework which in turns use jersey. It goes like this. @PATH(/user) @GET public Response getUser(@QueryParam("id") String userId) { assertNotNull(userId); try { User user = service.getUser(userId); return Response.ok(user).build(); } catch (MyOwnException moe) { //basically 400's return Response.status(400).entity(moe.getMsg())

Jersey @Produces Apache XSSFWorkbook

守給你的承諾、 提交于 2019-12-06 04:18:47
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 type application/xml was not found ... 37 more Essentially I have a function which creates the

Custom MOXyJsonProvider in Jersey 2 not working?

前提是你 提交于 2019-12-06 04:13:26
问题 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();

JAX-RS: Custom SecurityContext has unexpected type when injected into resource method

青春壹個敷衍的年華 提交于 2019-12-06 04:05:39
I have implemented a ContainerRequestFilter that performs JWT-based authentication: @Provider @Priority(Priorities.AUTHENTICATION) public class AuthenticationFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { AuthenticationResult authResult = ... if (authResult.isSuccessful()) { // Client successfully authenticated. // Now update the security context to be the augmented security context that contains information read from the JWT. requestContext.setSecurityContext(new JwtSecurityContect(...)); } else { // Client

How to get source address / ip from inside ContainerResponseFilter

懵懂的女人 提交于 2019-12-06 03:55:03
I'm writing a logging filter that logs all HTTP requests / responses for a web app running in Jersey. ContainerResponseFilter seems to a straight forward solution and I've managed to get it to work. Next step is to log the IP of the requests. Is there a way to do that from inside the ContainerResponseFilter ? Short answer: @Provider public class YourContextFilter implements ContainerRequestFilter { @Context private HttpServletRequest sr; @Override public synchronized void filter(ContainerRequestContext request) throws IOException { /* * Returns the Internet Protocol (IP) address of the client

Java Jersey使用總結

ぐ巨炮叔叔 提交于 2019-12-06 03:16:51
关于作者 马隆博(Lenbo Ma),Java,Javascript Blog: http://mlongbo.com E-Mail:mlongbo at gmail.com 创建于:2013/07/26 转载请注明出处: http://mlongbo.com/2015/Java Jersey2使用总结/ 前言 在短信平台一期工作中,为便于移动平台的开发,使用了Java Jersey框架开发RESTFul风格的Web Service接口。在使用的过程中发现了一些问题并积累了一些经验。因此,做下总结备忘,同时也希望对有需要的同仁有好的借鉴和帮助。 简介 Jersey是JAX-RS(JSR311)开源参考实现用于构建 RESTful Web service,它包含三个部分: 核心服务器(Core Server) :通过提供JSR 311中标准化的注释和API标准化,可以用直观的方式开发RESTful Web服务。 核心客户端(Core Client) :Jersey客户端API能够帮助开发者与RESTful服务轻松通信; 集成(Integration) :Jersey还提供可以轻松继承Spring、Guice、Apache Abdera的库。 在本次开发中使用Jersey2.0,并且仅使用了核心服务器。 设置Jersey环境 Maven <!--jersey-->