java - Problems Resteasy 3.09 CorsFilter -


i tried use new corsfilter available in resteasy 3.0.9. found example @ bottom of page: ajax request jax-rs/resteasy implementing cors

if define filter in method getsingletons() (of application subclass) , resources don't scanned anymore. means no resources found , following error occurs:

javax.ws.rs.notfoundexception: not find resource full path error occures

on following page found description: javax.ws.rs.notfoundexception: not find resource full path error occures

but basically, deployment option scan annotations of @path, @provider, etc application. reason jax-rs first classes , object in overridden getclasses() , getsingletons(), respectively. if return empty sets, tell jax-rs scanning (per spec).

so jax-rs doesn't scanning if overwrite getsingletons() method? there way configure corsfilter , enable resource scanning`?

"is there way configure corsfilter , enable resource scanning?"

one way keep scanning implement javax.ws.rs.core.feature

import javax.ws.rs.core.feature; import javax.ws.rs.core.featurecontext; import javax.ws.rs.ext.provider; import org.jboss.resteasy.plugins.interceptors.corsfilter;  @provider public class corsfeature implements feature {      @override     public boolean configure(featurecontext context) {         corsfilter corsfilter = new corsfilter();         corsfilter.getallowedorigins().add("*");         context.register(corsfilter);         return true;     }   } 

this feature scanned other @providers , @paths.

test

@applicationpath("/api") public class restapplication extends application { } 

c:\>curl -i http://localhost:8080/api/simple -h "origin:stackoverflow.com" http/1.1 200 ok date: wed, 01 apr 2015 12:07:22 gmt access-control-allow-credentials: true access-control-allow-origin: stackoverflow.com content-type: application/octet-stream content-length: 15 server: jetty(9.2.4.v20141103)

hello response!


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -