Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!