jersey

How to Convert a Properties Object to JSON Object with JAXB

早过忘川 提交于 2019-12-28 06:53:28
问题 I want to accept and respond JSON objects in a REST Application. The data I need to send and receive are in a .properties file. I have already read them and are now in a Properties Object(From java.util.Properties ). Is there a way to marshal and unmarshal Properties Objects, without implementing a new class? I am using Jax-rs API in a Weblogic server. @POST @Path("{id}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public JSONObject getbyID(@PathParam("id"

@Path and regular expression (Jersey/REST)

耗尽温柔 提交于 2019-12-28 05:50:22
问题 I'm using Jersey in a REST project and I'm needing to use regular expression . Digging about it is simple like: @Path("/resources") public class MyResource { @GET @Path("{subResources:.*}") public String get(@PathParam("subResources") String subResources) {...} } But, doing like this, the method is getting the request only if I passes 1 param, example: GET: .../resources/firstSubResource If I use more then 1 parameter the method is not getting the request, example: GET: .../resources

How to return a PNG image from Jersey REST service method to the browser

蹲街弑〆低调 提交于 2019-12-28 02:24:04
问题 I have a web server running with Jersey REST resources up and I wonder how to get an image/png reference for the browsers img tag; after submitting a Form or getting an Ajax response. The image processing code for adding graphics is working, just need to return it somehow. Code: @POST @Path("{fullsize}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces("image/png") // Would need to replace void public void getFullImage(@FormDataParam("photo") InputStream imageIS, @FormDataParam("submit")

What exactly is the ResourceConfig class in Jersey 2?

不羁岁月 提交于 2019-12-27 11:53:33
问题 I have seen a lot of Jersey tutorials that starts with something like @ApplicationPath("services") public class JerseyApplication extends ResourceConfig { public JerseyApplication() { packages("com.abc.jersey.services"); } } without explaining what exactly the ResourceConfig class is. So where can I find its documentation, usage, etc.? Googling for "jersey resourceconfig" does not yield any official doc. Some of my questions about this class and its usage are: What things can I do inside the

How to inject an object into jersey request context?

喜你入骨 提交于 2019-12-27 11:06:54
问题 I have this scenario where I want to write a filter and I want this filter to insert some object into the current request and pass it on so that when the resource class gets the request it can use the object. Filter class @Override public void filter(ContainerRequestContext request) throws IOException { MyObject obj = new MyObject(); // Inject MyObject to request which I dont know how } Resource Class @PUT @Consumes("application/json") @Path("/") public String create( JSONParam sample,

How to inject an object into jersey request context?

老子叫甜甜 提交于 2019-12-27 11:05:48
问题 I have this scenario where I want to write a filter and I want this filter to insert some object into the current request and pass it on so that when the resource class gets the request it can use the object. Filter class @Override public void filter(ContainerRequestContext request) throws IOException { MyObject obj = new MyObject(); // Inject MyObject to request which I dont know how } Resource Class @PUT @Consumes("application/json") @Path("/") public String create( JSONParam sample,

Start java application with jetty without WAR file

佐手、 提交于 2019-12-25 16:26:29
问题 I try start Jersey + Jetty + Nginx via this tutorial and I cannot use war file. How can I start my java application? I start application by right click on BackendServer.java and click "Run" in IDEA or using in terminal java -cp /home/example/backend/build/WEB-INF/lib/backend.jar:/home/example/backend/libs/* com.example.backend.BackendServer . Project structure is described here. /opt/jetty/webapps/backend.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay

Parsing JSON in JAVA usng Gson

自古美人都是妖i 提交于 2019-12-25 12:14:58
问题 So I am trying to parse a JSON object in Java using Gson. I am trying to consume an API from a website. This is the ticker: https://api.coinmarketcap.com/v1/ticker/bitcoin/ The JSON looks like this: [ { "id": "bitcoin", "name": "Bitcoin", "symbol": "BTC", "rank": "1", "price_usd": "3591.95", "price_btc": "1.0", "24h_volume_usd": "3263990000.0", "market_cap_usd": "59516499433.0", "available_supply": "16569412.0", "total_supply": "16569412.0", "percent_change_1h": "1.02", "percent_change_24h":

Parsing JSON in JAVA usng Gson

守給你的承諾、 提交于 2019-12-25 12:14:50
问题 So I am trying to parse a JSON object in Java using Gson. I am trying to consume an API from a website. This is the ticker: https://api.coinmarketcap.com/v1/ticker/bitcoin/ The JSON looks like this: [ { "id": "bitcoin", "name": "Bitcoin", "symbol": "BTC", "rank": "1", "price_usd": "3591.95", "price_btc": "1.0", "24h_volume_usd": "3263990000.0", "market_cap_usd": "59516499433.0", "available_supply": "16569412.0", "total_supply": "16569412.0", "percent_change_1h": "1.02", "percent_change_24h":

java.lang.NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J

半城伤御伤魂 提交于 2019-12-25 08:08:11
问题 I am using arquillian to do integration tests against a Restful java API, these tests are executed using @RunAsClient annotation, the application is deployed on Wildfly 9. The application tests were working but suddenly brake. I am getting this error: javax.ws.rs.ProcessingException: org.glassfish.jersey.client.ClientRequest.getLengthLong()J that seems to be caused by this one: Caused by: java.lang.NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J A piece of code: