Jetty context.xml overrideDescriptor not working for CORS

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Jetty context.xml overrideDescriptor not working for CORS

Harsh Prasad
Hi,

I have been trying to enable CORS on a jetty server using overrideDescriptor tag in context.xml. The override-web.xml is as follows:

<web-app>
 <filter>
    <filter-name>cross-origin</filter-name>
    <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
    <init-param>
        <param-name>allowedOrigins</param-name>
        <param-value>*</param-value>
    </init-param>
    <init-param>
        <param-name>allowedMethods</param-name>
        <param-value>GET,POST,DELETE,PUT,HEAD</param-value>
    </init-param>
    <init-param>
        <param-name>allowedHeaders</param-name>
        <param-value>origin, content-type, accept</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>cross-origin</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
I have added the following line in my jetty-context.xml
<Set name="overrideDescriptor">/path/to/override-web.xm</Set>
When Jetty is started i can see in the Debug logs that CrossOriginFilter is initialised properly. But i am still getting No 'Access-Control-Allow-Origin' header is present on the requested resource. I don't know why is this happening. 
Can someone suggest the reason or how to fix this? Can the original web.xml interfere with the overrideDescriptor?
Any help is appreciated.
Thanks,
Harsh


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Jetty context.xml overrideDescriptor not working for CORS

Jan Bartel-3
Jetty version?

Jan

On 6 March 2015 at 14:10, Harsh Prasad <[hidden email]> wrote:

> Hi,
>
> I have been trying to enable CORS on a jetty server using overrideDescriptor
> tag in context.xml. The override-web.xml is as follows:
>
> <web-app>
>  <filter>
>
>     <filter-name>cross-origin</filter-name>
>
> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
>     <init-param>
>         <param-name>allowedOrigins</param-name>
>         <param-value>*</param-value>
>     </init-param>
>     <init-param>
>         <param-name>allowedMethods</param-name>
>         <param-value>GET,POST,DELETE,PUT,HEAD</param-value>
>     </init-param>
>     <init-param>
>         <param-name>allowedHeaders</param-name>
>         <param-value>origin, content-type, accept</param-value>
>     </init-param>
> </filter>
> <filter-mapping>
>     <filter-name>cross-origin</filter-name>
>    <url-pattern>/*</url-pattern>
> </filter-mapping>
> </web-app>
>
> I have added the following line in my jetty-context.xml
>
> <Set name="overrideDescriptor">/path/to/override-web.xm</Set>
>
> When Jetty is started i can see in the Debug logs that CrossOriginFilter is
> initialised properly. But i am still getting No
> 'Access-Control-Allow-Origin' header is present on the requested resource. I
> don't know why is this happening.
>
> Can someone suggest the reason or how to fix this? Can the original web.xml
> interfere with the overrideDescriptor?
>
> Any help is appreciated.
>
> Thanks,
>
> Harsh
>
>
>
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <[hidden email]>
www.webtide.com
'Expert Jetty/CometD developer,production,operations advice'
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Jetty context.xml overrideDescriptor not working for CORS

Simone Bordet-2
In reply to this post by Harsh Prasad
Hi,

On Fri, Mar 6, 2015 at 4:10 AM, Harsh Prasad <[hidden email]> wrote:

> Hi,
>
> I have been trying to enable CORS on a jetty server using overrideDescriptor
> tag in context.xml. The override-web.xml is as follows:
>
> <web-app>
>  <filter>
>
>     <filter-name>cross-origin</filter-name>
>
> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
>     <init-param>
>         <param-name>allowedOrigins</param-name>
>         <param-value>*</param-value>
>     </init-param>
>     <init-param>
>         <param-name>allowedMethods</param-name>
>         <param-value>GET,POST,DELETE,PUT,HEAD</param-value>
>     </init-param>
>     <init-param>
>         <param-name>allowedHeaders</param-name>
>         <param-value>origin, content-type, accept</param-value>
>     </init-param>
> </filter>
> <filter-mapping>
>     <filter-name>cross-origin</filter-name>
>    <url-pattern>/*</url-pattern>
> </filter-mapping>
> </web-app>
>
> I have added the following line in my jetty-context.xml
>
> <Set name="overrideDescriptor">/path/to/override-web.xm</Set>
>
> When Jetty is started i can see in the Debug logs that CrossOriginFilter is
> initialised properly. But i am still getting No
> 'Access-Control-Allow-Origin' header is present on the requested resource. I
> don't know why is this happening.

The COF debug logs should say what's happening to the request and you
should be able to understand why the filter did not apply.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users