• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

No 'Access-Control-Allow-Origin' header is present on the requested resource

 
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to create a web service and its client.
Web service - JAX- RS (Using jersey for that i.e org.glassfish.jersey.containers)
Client - an Ajax request calling that service.
Basically this webservice data will be accessed from a mobile. So i have to keep domain different.

Code for Webservice's one of the method which I am calling through ajax.


Ajax code.



And the error is "XMLHttpRequest cannot load http://localhost:8080/TestService/rest/CategoryList No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. "

I searched on the same error on google but not able to find the solution.
Please can any one suggest a solution?
 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After a rigorous research i found out the solution. May be helpful to someone.
here is the solution.

2 Steps:

1) added a dependency in pom.xml


2) Added a filer mapping in the web.xml



And thats it. it all worked for me.
Cheers guys.
 
reply
    Bookmark Topic Watch Topic
  • New Topic