resteasy

MultipartForm handling with Spring

谁说我不能喝 提交于 2019-12-10 13:53:45
问题 This code is a RestEasy code for handling upload: @Path("/fileupload") public class UploadService { @POST @Path("/upload") @Consumes("multipart/form-data") public Response create(@MultipartForm FileUploadForm form) { // Handle form } } Is there anything similar using Spring that can handle MultipartForm just like this? 回答1: Spring includes has a multipartresolver that relies on commons-fileupload, so to use it you have to include it in your build. In your applicationContext.xml <bean id=

Resteasy Client java.lang.IllegalStateException: Response is closed

删除回忆录丶 提交于 2019-12-10 13:19:17
问题 I am getting below exception in RestEasy client -3.0.8 12:46:19,724 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) java.lang.IllegalStateException: Response is closed. I have write below code client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(request.getUrl()); Response response = target.request().accept(APPLICATION_TYPE_XML).header(TOKEN, request.getToken()).post(Entity.entity(request.getXmlObject(), APPLICATION_TYPE_XML)); output = response.readEntity

Return HTTP error from RESTeasy interface

亡梦爱人 提交于 2019-12-10 13:12:56
问题 Is it possible to return a HTTP error from a RESTeasy interface? I am currently using chained web-filters for this but I want to know if it is possible straight from the interface... Example sudo-code: @Path("/foo") public class FooBar { @GET @Path("/bar") @Produces("application/json") public Object testMethod(@HeaderParam("var_1") @DefaultValue("") String var1, @HeaderParam("var_2") @DefaultValue("") String var2 { if (var1.equals(var2)) { return "All Good"; } else { return HTTP error 403; }

How to read JBoss Resteasy's servlet request twice while maintaing @FormParam binding?

我与影子孤独终老i 提交于 2019-12-10 12:29:45
问题 I'm using JBoss' Resteasy as our JAX-RS provider. We have a requirement to read the servlet request body for authentication purpose, the problem is once the InputStream is read in the request, it cannot be read again, hence @FormParam won't work unless I can somehow "put the content back". I've tried the following two options: Using Resteasy's PreProcessInterceptor, I was able to read the body, but there's no way to reset the InputStream or add a wrapper type. The documentation doesn't

Serving static content in UndertowJaxrsServer

*爱你&永不变心* 提交于 2019-12-10 11:58:41
问题 I'm trying to serve static content through a ResourceHandler in my Undertow server that has a RestEasy deployment. public class Server { public static void main(String[] args) throws Exception { UndertowJaxrsServer server = new UndertowJaxrsServer(); Undertow.Builder serverBuilder = Undertow .builder() .addHttpListener(8080, "0.0.0.0") .setHandler( Handlers.path().addPrefixPath( "/web", new ResourceHandler(new PathResourceManager(Paths.get("/some/fixed/path"),100)) .setDirectoryListingEnabled

java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)

不羁的心 提交于 2019-12-10 10:53:36
问题 I'm trying to port an application using Weld 1.1.8 to Google App Engine. I'm using a listener in web.xml to bootstrap Weld: <listener> <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> </listener> The application starts fine on a regular Jetty 7. But upon bootstrapping on GAE, things go wrong: com.google.common.collect.ComputationException: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers) at com.google.common

Using RESTeasy on Tomcat

最后都变了- 提交于 2019-12-10 09:52:15
问题 I am new to restful web services.One of my client given me some methods with resteasy implementation those methods i have use in my project.I am using apache tomcat server in my project.can these methods will run on apache tomcat server or not??? 回答1: Yes it's possible. You need to add the RESTeasy implementation jars/dependencies. For Maven (resteasy.version == 3.0.9.Final) <!-- Basic support --> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId>

Integrating Jetty with RESTEasy

╄→尐↘猪︶ㄣ 提交于 2019-12-10 03:19:02
问题 Any links on how to integrate Jetty and RESTEasy? I am kinda stuck trying to configure RESTEasy with Jetty together....and there seems to be no credible help on the web. public static void main(String[] args) throws Exception { Server server = new Server(8080); WebAppContext context = new WebAppContext(); context.setDescriptor("../WEB-INF/web.xml"); context.setResourceBase("../src/webapp"); context.setContextPath("/"); context.setParentLoaderPriority(true); server.setHandler(context); server

Call ExceptionMapper from another ExceptionMapper in JAX-RS

元气小坏坏 提交于 2019-12-10 02:58:26
问题 In my RESTEasy application I'm getting a java.lang.reflect.UndeclaredThrowableException , because a checked exception is being thrown from a method that doesn't declare the exception in the throws clause. So I'm writing an UndeclaredThrowableExceptionMapper . The UndeclaredThrowableException wraps the real exception; I call e.getCause() to retrieve it. Can I then throw it or somehow look up the proper ExceptionMapper to handle it? 回答1: You can try adding a @Context javax.ws.rs.ext.Providers

keycloak error : Unrecognized field “access_token”

僤鯓⒐⒋嵵緔 提交于 2019-12-10 00:51:47
问题 I'm using keycloak to secure my rest API, I followed this tutorial to PROGRAMMATICALLY ADDING USERS, but I get that error message: ERROR [io.undertow.request] (default task-9) UT005023: Exception handling request to /service/secured: org.jboss.resteasy.spi.UnhandledException: javax.ws.rs.client.ResponseProcessingException: javax.ws.rs.ProcessingException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "access_token" (class org.keycloak.representations