What is the proper replacement of the Resteasy 3.X PreProcessInterceptor?

RESTEasy 3.x.x conforms to the JAX-RS 2.0 specification. What you are trying to do could be accomplished (maybe better) with: @Provider public class SecurityInterceptor implements javax.ws.rs.container.ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext){ if (not_authenticated){ requestContext.abortWith(response)}; } } since the ReaderInterceptor is invoked only if the underlying MessageBodyReader.readFrom is called by the standard JAX-RS pipeline, not … Read more

Propagating ThreadLocal to a new Thread fetched from a ExecutorService

The set of ThreadLocal instances associated with a thread are held in private members of each Thread. Your only chance to enumerate these is to do some reflection on the Thread; this way, you can override the access restrictions on the thread’s fields. Once you can get the set of ThreadLocal, you could copy in … Read more

Optional @PathParam in Jax-RS

The problem was the lack of whitespace before the colon: @Path(“/mypath{param1: (/param1)?}”) should be: @Path(“/mypath{param1 : (/param1)?}”) Apparently it’s a bug, because the specification makes the whitespace around the colon optional. I also found that I’m not the first bitten by this bug.

PersistenceContext EntityManager injection NullPointerException

An entity manager can only be injected in classes running inside a transaction. In other words, it can only be injected in a EJB. Other classe must use an EntityManagerFactory to create and destroy an EntityManager. Since your TestService is not an EJB, the annotation @PersistenceContext is simply ignored. Not only that, in JavaEE 5, … Read more

Logging request and response in one place with JAX-RS

You can create filters and easily bind them to the endpoints you need to log, keeping your endpoints lean and focused on the business logic. Defining a name binding annotation To bind filters to your REST endpoints, JAX-RS provides the meta-annotation @NameBinding and it can be used as following: @NameBinding @Retention(RUNTIME) @Target({TYPE, METHOD}) public @interface … Read more

How to choose between Jersey, Apache Wink and JBoss RESTEasy? [closed]

JAX-RS Implementations Jersey Reference Implementation Usually the most cutting edge Supports true asynchronous (ie web sockets etc…) connections through either Atmosphere or 2.0 version. Has support for Spring and standard injection containers (ie @Inject). Glassfish bundles it. Its much more modular than the other JAX-RS projects. It has a kick ass URI Builder Does not … Read more

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

The problem is the JSON – this cannot, by default, be deserialized into a Collection because it’s not actually a JSON Array – that would look like this: [ { “name”: “Test order1”, “detail”: “ahk ks” }, { “name”: “Test order2”, “detail”: “Fisteku” } ] Since you’re not controlling the exact process of deserialization (RestEasy … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)