jersey

Eclipse java - How do I include Jersey archetype in Maven?

寵の児 提交于 2019-12-13 16:23:32
问题 I am trying to create a Webapp using Maven Jersey archetype, but while I am searching it, it's not giving me any result. Can you please if I need to set up anything for this or how do I get the search result for this? Expected: Actual: 回答1: You need to add the Jersey Maven Archetype to your Eclipse because your catalog is not the lastest version. Go to Preferences -> Maven -> Archetypes ->Add Remote Catalog and add these parameters: Catalog File: http://repo1.maven.org/maven2/archetype

MessageBodyWriter not found for media type=text/html but works for JSON

隐身守侯 提交于 2019-12-13 15:17:54
问题 The problem is that whenever I try to produce response of media type anything other than JSON, I get "MessageBodyWriter" not found error. But the response works fine for Application_JSON outputs. I am using several dependencies in my Maven POM so maybe MessageBodyWriter is getting overridden or maybe only for JSON its included. Here are the pom dependencies - <dependencies> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.2-1003-jdbc4</version> <

Could not parse date in RESTful application with Jersey

岁酱吖の 提交于 2019-12-13 14:49:53
问题 I do RESTful application to accept and save the date. When I call it with the following JSON {"date": "1997-07-16T19: 20: 30 + 01: 00", "count": 1} I get the error listed below. Without date it works well. I use jersey.version 2.5.1 and eclipselink.version 2.5.2-M1. How do I fix this? Resource @POST @Path(value = "/") @Consumes(MediaType.APPLICATION_JSON) public Response saveDate(DateMapper date) { dateService.save(date); return Response.status(Response.Status.OK).entity("Date has been

Jersey REST/ JAXB error , mapping an Interface

烂漫一生 提交于 2019-12-13 14:23:21
问题 I have to use an interface in my REST web service. Here is the Interface Specs.java : @XmlJavaTypeAdapter(MyAdapter.class) public interface Specs { public BaseProperties getBaseProps(); public void setBaseProps(BaseProperties baseProps); } MyAdapter.java : public class MyAdapter extends XmlAdapter<Object,Object> { public Object unmarshal(Object v) { return v; } public Object marshal(Object v) { return v; } } RegSpecs.java @XmlType public class RegSpecs implements Specs{ private BaseProperties

@Context injection not working in Jersey ContainerRequestFilter (Dropwizard)

ⅰ亾dé卋堺 提交于 2019-12-13 13:28:23
问题 @Context injection works with classes but not able to make it work with Objects. httpServletRequest in ContainerRequestFilter produces null pointer. Dropwizard Version:- 1.1.0 ContainerRequestFilter public class ApplicationIPAuthFilter implements ContainerRequestFilter { private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationIPAuthFilter.class); private HerculesRestAccessor restAccessor; private String applicationName; @Context private HttpServletRequest httpServletRequest;

getting Invalid byte tag in constant pool : 19

▼魔方 西西 提交于 2019-12-13 12:34:33
问题 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. 回答1: 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

Jersey + Moxy + JAXB - how to marshal XML without annotations

谁说胖子不能爱 提交于 2019-12-13 12:17:38
问题 In http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html about halfway down there's a heading "Customizing the JSON-Binding". How do you similarly customize the XML binding? There seem to be fundamental differences between the way Jersey handles Moxy JSON binding and the XML equivalent. If I follow the instructions in the Jersey documentation for creating a custom JAXBContext resolver to configure Moxy's mapping file, that resolver fires in the JSON case but not in the XML

Get all html form param name & value using jersey

自古美人都是妖i 提交于 2019-12-13 12:17:07
问题 I have a html form which contains elements like this <input type="text" value="Val1" name="Name1"/> <input type="text" value="Val2" name="Name2"/> <input type="hidden" value="Val3" name="Name3"/> On server side, i use Jersey implementation to capture the form name and values. Is there a way to capture all of the above in a single Map like this Name1 ==> Val1 Name2 ==> Val2 Name3 ==> Val3 I understand that using @FormParam, i can capture the form value in a variable . But i need to capture the

Severe error for using “multipart/form-data” for a file upload service - Apache Jersey

会有一股神秘感。 提交于 2019-12-13 12:14:16
问题 I get this error: SEVERE: Resource methods utilizing @FormParam and consuming "multipart/form-data" are no longer supported. See @FormDataParam When a client web access is done for a Apache Jersey based Rest web service I am working right now: @POST @Path("upload") @Consumes("multipart/form-data") @Produces("text/plain") public String uploadFile(@FormParam("file") File file, @FormParam("file") FormDataContentDisposition fileDetail) { String fileLocation = "/files/" + fileDetail.getFileName();

Using Server Request and Response filters for ThreadLocal storage in a RestEasy based service

瘦欲@ 提交于 2019-12-13 12:12:46
问题 I am currently working on a RESTeasy based RESTful service. I have a filter class which serves as a server request filter as well as a server response filter (i.e. it implements ContainerRequestFilter and ContainerResponseFilter interfaces). At the beginning of the request, I use the filter to put an object into ThreadLocal . This object is used by the resources throughout the request. At the end of the request, before sending out the response, the filter removes the object from ThreadLocal .