[x-posting to users_at_glassfish.com]
On 2/4/2015 12:36 PM, Paulo Reis wrote:
> Hi,
>
> We’re tryin’ few java 8 features with JAVA EE 7 using glassfish v4.1.
>
> JAX-RS is not able to work with @Path annotation when used in a method
> implementation inside an interface.
> Example:
>
> /public interface Controller {/
> /
> /
> /_at_GET/
> /default Response ok() {// it works/
> /return Response.ok.build();/
> /}/
> /
> /
> /_at_GET/
> /_at_Path(“error”)/
> /default Response error() { // doesn’t work/
> / return Response.ok.build();/
> /}/
> /
> /
> /_at_Produces({APPLICATION_JSON})
> @Consumes({APPLICATION_JSON})
> @LocalBean
> @Stateless
> /
> /public class ControllerImplementation implements Controller {/
> /
> /
> /}/
>
> When you try to run with the second method *uncommented*, JAX-RS
> throws exception when it tries to initialize the REST stack. Weird
> ‘cause @GET/_at_POST works, only @Path gives error.
>
> Another weird situation happens when you try to annotate your
> interface methods with @TransactionAttribute annotation. EJB is unable
> to check that info and open a transaction, thus giving an error
> (TransactionRequired).
>
> To fix that, you have to override the method in your implementation
> class and call the *super*, and then the transaction gets opened.
>
> Example:
>
> /public interface Controller {/
> /
> /
> /_at_POST/
> /_at_TransactionAttribute(TransactionAttributeType.MANDATORY)/
> /default Response create(JsonObject obj) {/
> / return Response.ok.build();/
> / }/
> /
> /
> /_at_Produces({APPLICATION_JSON})
> @Consumes({APPLICATION_JSON})
> /
> /public class ControllerImplementation implements Controller {/
> / // you must override to make the transaction available,
> otherwise it will fail!/
> / @Override /
> / @POST/
> / public Response create(JsonObject obj) {/
> / super.create(obj);/
> / }/
> /}/
> /
> /
>
> So it seems we cannot use all features that java 8 brings without
> having headache with JAVA EE 7. Does anybody knows why this happens?
>
> Thanks.