jersey

NameNotfoundException in Jetty 9 at mail session resource JNDI lookup

只愿长相守 提交于 2019-12-25 01:39:02
问题 I'm writing a REST API backend servlet with Jersey, and I have some problems using jndi to configure mail sending. Here's my WEB-INF/jetty-env.xml: <?xml version="1.0"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <Configure id='wac' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="mail" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="wac"/></Arg> <Arg>mail/Session</Arg> <Arg> <New class="org

Get jersey/jackson json into several classes

折月煮酒 提交于 2019-12-25 00:30:03
问题 I have this json response from a server. {"session_key":"thekey","expires_in":300,"environment":"exttest","country":"SE","private_feed":{"hostname":"priv.api.test.nordnet.se","port":443,"encrypted":true},"public_feed":{"hostname":"pub.api.test.nordnet.se","port":443,"encrypted":true}} The top level info is parsed fine into the below class. But how do I populate the list of server info? The code Response response = baseResource.path("login").queryParam("service", "NEXTAPI") .queryParam("auth",

Dumping bad requests

你离开我真会死。 提交于 2019-12-25 00:27:23
问题 I have a service implemented with Dropwizard and I need to dump incorrect requests somewhere. I saw that there is a possibility to customise the error message by registering ExceptionMapper<JerseyViolationException> . But I need to have the complete request (headers, body) and not only ConstraintViolations . 回答1: You can inject ContainerRequest into the ExceptionMapper . You need to inject it as a javax.inject.Provider though, so that you can lazily retrieve it. Otherwise you will run into

RESTeasy and the @MultipartForm , server and client

大憨熊 提交于 2019-12-24 22:28:34
问题 Walking through the RESTEasy Guide 4.4.0-final from jboss. Having the examples to guide be as well. Wanting to create a small service where you post a binary-file with some metadata. In this particular case I would like to post a file + 'the owner of that file'. In my first effort I am using the following construct (1st-attempt-server). @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile(@FormDataParam("file") InputStream is, @FormDataParam("file")

jquery $.ajax cross-domain GET works but not POST

守給你的承諾、 提交于 2019-12-24 20:27:14
问题 I cannot figure out why a GET cross-domain request is working, but the POST request using the exact same server URL is not. I have set the following response headers set on the server (using JERSEY) for ALL request methods (GET, POST, PUT, DELETE, and OPTIONS): header("Access-Control-Allow-Origin", "*") header("Access-Control-Allow-Credentials", "true") header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") header("Access-Control-Allow-Headers", "accept, origin,

Empty content-type while downloading file with Jersey client

旧巷老猫 提交于 2019-12-24 20:00:31
问题 I'm trying to download a file with the Jersey client. I'm requesting an API, and I don't have API source code. For one URL, the API returns an empty "Content-Type" header (the header is present but empty). Jersey does not like this: Unable to parse "Content-Type" header value: "" I'd like to keep the Jersey client if possible Is an API supposed to return an empty content-type? Is there any header I can add to my request that may solve the problem? I tried content-type and accept without

ResourceInfo not injected into spring managed jersey filter

 ̄綄美尐妖づ 提交于 2019-12-24 19:24:58
问题 I am having problems injecting the ResourceInfo into my jersey filter. The annotation @Context doesn't seem to work properly when having a spring managed filter instance. What I found is this: Jersey Request Filter only on certain URI The second goal is quite similar to my situation. DynamicFeature: @Provider public class HttpCacheConfigDynamicFeature implements DynamicFeature { private final DefaultHttpCacheFilter defaultHttpCacheFilter; private final HttpCacheFilter httpCacheFilter;

Validating queryparam values jersey

不羁岁月 提交于 2019-12-24 18:18:46
问题 Are there any other ways besides the one below to validate query parameter values i.e. is there a Jersey way to this by mapping to a schema via a wadl. Thank you @Path("smooth") @GET public Response smooth( @DefaultValue("blue") @QueryParam("min-color") ColorParam minColor, public class ColorParam extends Color { public ColorParam(String s) { super(getRGB(s)); } private static int getRGB(String s) { if (s.charAt(0) == '#') { try { Color c = Color.decode("0x" + s.substring(1)); return c.getRGB

REST JAX-RS Logging

China☆狼群 提交于 2019-12-24 17:31:22
问题 I have followed the HelloWorld example and got my fist REST done successfully. Now, I would like to add the logging capability the code. For example, I would like to have any logging frameworks (Log4j, JUL) and be able to log in the code, and have output to a file. How do I implement the logging to my REST code? @Path("/hello") public class HelloWorldService { Logger log = Logger.getLogger("className"); @GET @Path("/{param}") public Response getMsg(@PathParam("param") String msg) { String

REST JAX-RS Logging

跟風遠走 提交于 2019-12-24 17:31:10
问题 I have followed the HelloWorld example and got my fist REST done successfully. Now, I would like to add the logging capability the code. For example, I would like to have any logging frameworks (Log4j, JUL) and be able to log in the code, and have output to a file. How do I implement the logging to my REST code? @Path("/hello") public class HelloWorldService { Logger log = Logger.getLogger("className"); @GET @Path("/{param}") public Response getMsg(@PathParam("param") String msg) { String