jax-rs

Parsing @Context UriInfo to java thread

谁说我不能喝 提交于 2020-01-11 07:49:06
问题 I'm trying to parse @Context UriInfo to another thread and do some task. But when i try to run it, it gives the error as Exception in thread "Thread-691" org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.UriInfo My code as follows @GET @Path("/thread") public void thread(@Context UriInfo url){ Runnable run = new Runnable() { @Override public void run() { System.out.println(">>>>>>>>>>>> " + url.getRequestUri().getQuery()); } }; Thread t = new

Adding JAR with ObjectMapper makes my ObjectMapper non-discoverable

狂风中的少年 提交于 2020-01-11 05:33:27
问题 How can I make my object mapper work in situation when there is another object mapper defined in jar from dependencies ? I'm trying to use Swagger with Jersey 2 which is being run under Jetty. The problem is that as soon as I add Swagger JAX-RX jar into classpath my object mapper is not discovered therefore I lose custom serialization of my objects. Here is how my object mapper defined @Provider public class ObjectMapperProvider implements ContextResolver<ObjectMapper> { } I've posted issue

How to make Jersey use GZip compression for the response message body

a 夏天 提交于 2020-01-10 22:30:03
问题 I am trying to write a simple Jersey application that sends files from a Jersey client to a Jersey server and back. However, the files only seem to be encoded on the way from the client to the server but not the other way. I wonder how I can change this behavior. I am testing this in a simple example: public class GZipEncodingTest extends JerseyTest { private static final String PATH = "/"; private static final String QUESTION = "foo", ANSWER = "bar"; private static final String ENCODING_GZIP

What is the proper place to register MessageBodyReader and MessageBodyWriter implementations?

纵饮孤独 提交于 2020-01-10 20:11:53
问题 I have implemented Javax WS RS API MessageBodyReader for com.ca.tas.crypto.cmp.client.GeneralPKIMessageJaxRsReader and MessageBodyWriter for org.bouncycastle.asn1.cmp.PKIMessage so that I can easily use the types in CMP over HTTP REST API. Now, to register the types I have created META-INF/services/javax.ws.rs.ext.Providers file and put the class names there. Everything works fine, I can do REST calls using the API, except: IntelliJ IDEA (or one of the plugins I have installed into it)

Jersey Rest webservice redirecting to the same page

妖精的绣舞 提交于 2020-01-10 05:33:27
问题 I have a simple rest webservice that will be used to load a page. Once the page is loaded the same page will be displayed with a confirmation msg or error msg being displayed. Im using the using the below code to load it .... jsp page:- <form action="rest/file/upload" method="post" enctype="multipart/form-data"> <br> <label>Username: &nbsp&nbsp&nbsp</label><input type="text" placeholder="Username" name="username"> <br> <br> <label>Password:&nbsp&nbsp&nbsp&nbsp&nbsp</label><input type="text"

Jersey REST extending methods

家住魔仙堡 提交于 2020-01-10 05:32:09
问题 I was wondering if it is possible to do the following trick with jersey restful resources: I have an example jersey resource: @Path("/example") public class ExampleRessource { @GET @Path("/test") @CustomPermissions({"foo","bar"}) public Response doStuff() { //implicit call to checkPermissions(new String[] {"foo","bar"}) } private void checkPermissions(String[] permissions) { //stuff happens here } } What I want to achieve is: before executing each resource's method to implicitly check the

Why does Jersey swallow my “Content-Encoding” header

邮差的信 提交于 2020-01-10 05:06:10
问题 Why does the following example swallow my HTTP-Header for "Content-Encoding" in the request. I am writing an application where I need to decode a custom encoding format. However, I can never get hold of the "Content-Encoding" header from the request. Neither in the actual resource nor in an ReaderInterceptor. In the response, this encoding header is not swallowed. This behavior can be easily observed in the following (runnable) example: public class Demo extends JerseyTest { @Override

How to customize namespace prefixes on Jersey(JAX-WS)

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-10 04:10:35
问题 when serializing my resources on Jersey, I want to use namespaces in some cases. Is there any way to customize the namespace prefixes on jersey? Default: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <order xmlns:ns2="http://www.w3.org/2005/Atom"> <price>123</price> <ns2:link rel="duh" href="/abc/123"/> <ns2:link rel="abc" href="/def/234"/> </order> I want something like: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <order xmlns:atom="http://www.w3.org/2005/Atom"> <price

Using Jersey 2.x web service on Weblogic 12.1.1

爷,独闯天下 提交于 2020-01-10 03:02:25
问题 I'm trying to deploy Jersey 2.13 web services to Weblogic 12.1.1. This version of weblogic is compliant with JSR-311 JAX-RS 1.1 specification whereas Jersey 2.x provides implementation for JAX-RS 2.0 Oracle has an instruction on how to upgrade the version of Jersey JAX-RS RI : http://docs.oracle.com/cd/E24329_01/web.1211/e24983/version.htm However even this doesn't help solving all of the deployment issues. I'm packaging the application in EAR containing WAR. In order to override weblogic

DropWizard Auth Realms

时间秒杀一切 提交于 2020-01-10 02:55:18
问题 In DropWizard, I can set up basic auth like so (in the Application#run impl): BasicAuthProvider<SimplePrincipal> authProvider = new BasicAuthProvider(authenticator, "SECRET_REALM"); environment.jersey().register(authProvider); I am wondering what the significance of the String realm (" SECRET_REALM ") is? From general security concepts, I understand a "realm" to be a place (database, directory, file, keystore, etc.) where users and roles/permissions are stored. What does a realm mean in