resteasy

Hibernate throwing a QuerySyntaxException with correct class name given

℡╲_俬逩灬. 提交于 2019-12-14 03:23:47
问题 I have a Product class; @Entity public class Product { . . public Product() { } . . } A generic DAO; public class GenericDao<T> { private Class<T> type; @Inject protected EntityManager entityManager; public GenericDao() { } public List<T> list() { return entityManager.createQuery("FROM " + type.getSimpleName(), type).getResultList(); } } A Product DAO class; public class ProductDao extends BaseDao<Product> { } A product JAX-RS service; @Path("/product") public class ProductService { @Inject

JAX-RS: Retrieve path pattern in ContainerRequestFilter

陌路散爱 提交于 2019-12-13 16:22:18
问题 I am implementing a pre matching ContainerRequestFilter and would like to retrieve the @Path pattern of my resource which is about to be invoked. Here is my resource Path("/v1/partner/{partnerId}/adresse") public interface AdresseResource { @GET @Produces({ MediaType.APPLICATION_JSON }) public Response handleAdresseCollectionGet(@Context UriInfo uriInfo, @PathParam("partnerId") String partnerId); // Other methods omitted } In my filter I would like to get the /v1/partner/{partnerId}/adresse

Cannot set timeout on Resteasy Client on JBoss

瘦欲@ 提交于 2019-12-13 16:11:39
问题 I am trying to create a rest client on a JBoss EAP server, and I need to make sure that a timeout will end the connection if it gets stuck. My code looks like this: int timeout = 5000; RequestConfig defaultRequestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setSocketTimeout(timeout).setConnectTimeout(timeout).build(); HttpClientBuilder builder = HttpClientBuilder.create(); HttpClient httpClient = builder.setDefaultRequestConfig(defaultRequestConfig).build(); //

Unexpected detached entities with extended persistent context

蓝咒 提交于 2019-12-13 13:37:13
问题 I'm trying to maintain state across multiple calls by using an EXTENDED_PERSISTENT_CONTEXT. My understanding is that managed entities will not detach between calls however I keep getting errors related to detached entities in calls after I have previously thrown validation errors. The state is being maintained in a stateful session bean: @Named(SessionFacadeBean.SEAM_NAME) @SessionScoped @Stateful @LocalBean @AccessTimeout(value = 10, unit = TimeUnit.SECONDS) public class SessionFacadeBean

How do I specify a web proxy when using RestEasy client proxy?

帅比萌擦擦* 提交于 2019-12-13 13:16:26
问题 I am using a RestEasy ProxyFactory to connecting to a REST service. However I need to connect via a web proxy. How do I specify the proxy connection details? At the moment I am creating the instance using: MyInterface instance = org.jboss.resteasy.client.ProxyFactory.create(MyInterface.class,url); instance.doStuff(); However, it does not connect. RestEasy seems to be using Apache Commons HTTPClient under the covers, which does not allow you to specify a proxy using the standard Java System

Using Server Request and Response filters for ThreadLocal storage in a RestEasy based service

瘦欲@ 提交于 2019-12-13 12:12:46
问题 I am currently working on a RESTeasy based RESTful service. I have a filter class which serves as a server request filter as well as a server response filter (i.e. it implements ContainerRequestFilter and ContainerResponseFilter interfaces). At the beginning of the request, I use the filter to put an object into ThreadLocal . This object is used by the resources throughout the request. At the end of the request, before sending out the response, the filter removes the object from ThreadLocal .

Disable logging of Exception in Bean

戏子无情 提交于 2019-12-13 07:23:46
问题 I'm using Wildfly 10 and JAX-RS (resteasy) and have a Bean being injected in another Bean: @Path("foo") public class FooResource { @Inject BarBean bar; ... } Then I'm calling a method on bar that throws a RuntimeException. I'm handling this Exception in FooResource , but Wildfly has interceptors that print the stack trace to the log. I don't want this to happen. Is there any way to disable this behavior? 回答1: I could only reproduce this when the @Inject ed bean was a EJB (with Wildfly-9). You

Wildfly, JAAS and SecurityContext

落花浮王杯 提交于 2019-12-13 07:17:18
问题 I'm still playin with Wildfly-9.0.1.Final and JAAS (see my previous question Wildfly and JAAS login module) in a web application that use a BASIC auth-method . While my custom login module works I got some problems about authorization. I use a RESTeasy RESTFul web service with annotation to test, here is the code: package it.bytebear.web.mongo; import it.bytebear.web.mongo.jaas.MongoModuleCallbackHandler; import it.bytebear.web.mongo.model.User; import java.security.Principal; import java

Reading a “properties” file

佐手、 提交于 2019-12-13 07:16:38
问题 I have a Rest service using Resteasy (running on top of Appengine), with the following psuedo code: @Path("/service") public class MyService { @GET @Path("/start") public Response startService() { // Need to read properties file here. // like: servletContext.getResourceAsStream("/WEB-INF/config.properties") } } However its obvious that the servlet context cannot be accessed here. And code like: InputStream inputStream = this.getClass().getClassLoader() .getResourceAsStream("/WEB-INF/config

POST complex parameters to REST service what would request URL and Body look like

不羁岁月 提交于 2019-12-13 06:55:20
问题 So I am standing up a rest service. It is going to request a post to a resource that is pretty complex. The actual backend requires multiple (19!) parameters. One of which is a byte array. It sounds like this is going to need to be serialized by the client and sent to my service. I am trying to understand how I can right a method that will handle this. I am thinking something like this @POST @Path("apath") @Consumes(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML) public Response randomAPI(