jersey

Integrating Jetty with JAX-RS-Jersey

Deadly 提交于 2019-12-18 10:24:14
问题 After an exhaustive search of the web and Stackoverflow, I am still stuck with trying to figure out how to integrate a RESTlet style interface provided by Jersey with Jetty. I have my Jetty server up and running and as such Jersey seems pretty easy to use as well, does anyone know how to tie the two together? Any concrete links would help — I am a little new to servlet programming as well. 回答1: I created an app using Jetty and Jersey a while back. It's just a standard webapp really: web.xml:

Jersey Jackson and codehaus vs. fasterxml

时间秒杀一切 提交于 2019-12-18 10:23:06
问题 I'm using Jersey 1.17.1 with Jackson 2.2.1. It seems like Jackson switched packages from org.codehaus to com.fasterxml . I have all my code configured properly and using the latest jackson. However, it seems like Jersey is still pulling in org.codehaus.jackson . Is there any way to mitigate this or should I stick with the codehaus packages until jersey is upgraded to use the fasterxml packages? 回答1: The older Jackson libraries are being pulled in as dependencies of the jersey-json artifact.

HK2 IterableProvider named method not finding Implementation

烈酒焚心 提交于 2019-12-18 09:35:14
问题 I have a problem trying to inject a contract with two services bound to it. I'm using Jersey, and extending ResourceConfig to configure my app, where I'm binding two different implementations (classes FooImpl1 and FooImpl2 ) to a same contract (interface Foo ), ranking them differently. Each of these implementations is annotated with @Named and its name. In one of my controllers I want to have access to both implementations, so I inject an IterableProvider<Foo> fooProvider . If I do not

Jersey RESTfull service with JSON

雨燕双飞 提交于 2019-12-18 09:05:12
问题 I want to parse the values from the JSON-Post into Java-Variables. But they are always empty! JSON-Post: {"algID":0,"vertices":[1,2,3]} My try to parse it into Java-Variables: @POST @Consumes(MediaType.APPLICATION_JSON) @Path("getCloseness_vertices") public String getCloseness_vertices( @FormParam("algID") int algID, @FormParam("vertices") IntArray vertices) If i try it like this: public String getCloseness_vertices(int algID) Tomcat says: A message body reader for Java class int, and Java

Jersey REST Client : Posting MultiPart data

依然范特西╮ 提交于 2019-12-18 08:55:53
问题 I am trying to write a Jersey client app which can post multi part form data to a Restful Jersey service. I need to post a CSV file with the data and a JSON with meta-data. I am using Jersey client 1.18.3. Here is my code (some names have been changed for company confidentiality )... Client client = Client.create(); WebResource webResource = client.resource("http://localhost:8080/mariam/service/playWithDad"); FileDataBodyPart filePart = new FileDataBodyPart("file", new File("C:/Users/Admin

Rules for Jersey to parse JSON/ Jackson Subtype deserialisation

不想你离开。 提交于 2019-12-18 08:54:14
问题 I receive JSONs the way: @POST @Path("log") public Map<String, List<OperationResult>> log(Stats stats) { .. } The examples of JSONs: { "eventType": 1 "params": { "field1" : 10 } } { "eventType": 2 "params": { "field2" : "ten" } } I have a class structure (they are generated by jsonschema2pojo, suppose it does not matter): interface Params; class Params1 implements Params{ public int field1; } class Params2 implements Params{ public String field2; } class Stats { public int eventType; public

Case-insensitive URLs with JAX-RS

淺唱寂寞╮ 提交于 2019-12-18 07:45:19
问题 Is there any easy way to provide a case-insensitive URLs in a JAX-RS web service? The goal of this is to produce a web service which is a "lenient acceptor." 1 I imagine it's possible to do this with a filter which .to[Lower|Upper]Case() s all incoming URLs. Unfortunately, this implementation demands programmer discipline/consistency in making sure that all hard-coded URL strings in the application are strictly [lower|upper]case. Also, I don't yet know the JAX-RS analog to a servlet filter.

java.lang.NoClassDefFoundError: Could not initialize class xxx.xxx.xxx.HibernateUtil

烂漫一生 提交于 2019-12-18 07:06:32
问题 Herewith I added my source code of web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name>ussd</display-name> <servlet> <servlet-name>init</servlet-name> <jsp-file>/init.jsp</jsp-file>

Java Jersey Jettison Message Body Reader Exception

安稳与你 提交于 2019-12-18 06:54:10
问题 I am a complete beginner at REST services but I need to access some information via REST from a web site. The service has some sample code to show how to login that I have used. The sample code uses Jettison as a JSON parser but when I try to run the following code snippet I get an Exception: JSONObject post = baseResource.path("login") .queryParam("service", "ABC").queryParam("auth", authParam) .accept(MediaType.APPLICATION_JSON_TYPE).post(JSONObject.class); baseResourse is a WebResource

java.lang.IllegalAccessError while trying to test a jersey REST webservice deployed on TomEE

给你一囗甜甜゛ 提交于 2019-12-18 06:53:52
问题 I have a Jersey-based REST webservice which is working fine when deployed on Glassfish. When I deploy the same war file on Apache TomEE+ 1.6 version, i get the exception java.lang.IllegalAccessError: tried to access method com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoader()Ljava/lang/ClassLoader; from class com.sun.jersey.spi.scanning.AnnotationScannerListener com.sun.jersey.spi.scanning.AnnotationScannerListener.<init>(AnnotationScannerListener.java:89) com.sun.jersey.spi