CORS For JAX-RS 2.0 / Java EE 7 Released

Cross-origin resource sharing support for Java EE 7 / JAX-RS 2.0 is released.

The following dependency in a WAR will install and setup the CORS extension automatically:


<dependency>
	<groupId>com.airhacks</groupId>
	<artifactId>jaxrs-cors</artifactId>
	<version>0.0.1</version>
	<scope>compile</scope>
</dependency>

CORS is opensource and Apache licensed: https://github.com/AdamBien/cors

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!

Comments:

Does not work !

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/AffableBean/rest/department/1. This can be fixed by moving the resource to the same domain or enabling CORS.

Posted by kacha on May 10, 2014 at 03:56 PM CEST #

It's crazy, with IE it works and with all other 4 Browsers (Firefox, Chrome, Opera, Safari) it fails.

Posted by kacha on May 11, 2014 at 01:03 PM CEST #

Not very useful, as there's no way to customize the CORS headers without hacking the library. I don't see the benefit of using this over creating your own Filter.

Posted by DR on July 20, 2014 at 05:21 AM CEST #

Great extension. Resolve CORS issue easily with it.

Posted by David on August 31, 2016 at 03:46 AM CEST #

I just added it to a JEE 7 project that uses Angular2 in the front-end, and it instantly solved my problem.

Posted by Larry Fredrickson on March 03, 2017 at 06:24 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License