I found this helpful. You will need to add a couple of additive banners and modify webdefault.xml to enable CORS.
I reproduce the text here:
In the solr project example, when you start it by calling the following line:
java -jar start
You start the Jetty server on your local machine, which will run the solr results. This server cannot run CORS (Cross Origin Resource Sharing). This means that if you try to make an AJAX call from a web page of a different origin than the server itself, you will be denied a response.
To fix this, you first need to get the right banks to allow resource sharing between domains.
I used the following jar: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/8.1.10.v20130312/
But you may need a version suitable for your version of the pier: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlets/
You can find out which version of Jetty you are using with your solr example by going to: java -jar start --version
and you will see the dump as follows: C: \ Users \ username \ Desktop \ solr-4.8.0 \ example> java -jar start.jar --version Active parameters: [default, *] Version information of 18 entries in the path to the classes. Note: the order presented here is how they appear on the class path. changes to OPTIONS = option [option, option, ...] will be displayed on the command line. repeatedly.
0: (dir) | ${jetty.home}\resources 1: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-xml-8.1.10.v20130312.jar 2: 3.0.0.v201112011016 | ${jetty.home}\lib\servlet-api-3.0.jar 3: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-http-8.1.10.v20130312.jar 4: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-continuation-8.1.10.v20130312.jar 5: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-server-8.1.10.v20130312.jar 6: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-security-8.1.10.v20130312.jar 7: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-servlet-8.1.10.v20130312.jar 8: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-webapp-8.1.10.v20130312.jar 9: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-deploy-8.1.10.v20130312.jar 10: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-servlets-8.1.10.v20130312.jar 11: 1.7.6 | ${jetty.home}\lib\ext\jcl-over-slf4j-1.7.6.jar 12: 1.7.6 | ${jetty.home}\lib\ext\jul-to-slf4j-1.7.6.jar 13: 1.2.16 | ${jetty.home}\lib\ext\log4j-1.2.16.jar 14: 1.7.6 | ${jetty.home}\lib\ext\slf4j-api-1.7.6.jar 15: 1.7.6 | ${jetty.home}\lib\ext\slf4j-log4j12-1.7.6.jar 16: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-util-8.1.10.v20130312.jar 17: 8.1.10.v20130312 | ${jetty.home}\lib\jetty-io-8.1.10.v20130312.jar
Look for the line that says $ {jetty.home} \ lib \ jetty-server (in the dump above line 5), and you can see your version.
You will also want to get "jetty-util" for your version of the pier: http://mvnrepository.com/artifact/org.mortbay.jetty/jetty-util
You can find your version there. I used jetty-util-8.1.10.v20130312.jar for my own.
Now take the downloaded servlet.jar and util.jar files and place them in the following folder: Solr-4.8.0 \ for example \ Lib
It may be different for your version, but you want it in the lib folder in the examples directory.
Finally, for these changes to be affected, you must open the solr-4.8.0 \ example \ etc \ webdefault.xml file
and add the following lines to </web-app>
:
<filter> <filter-name>cross-origin</filter-name> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Now reboot the server and you should have CORS.
Notes: If you start getting fancy and have several web applications running on the solr counter server, then this will affect all of these web applications. Keep in mind that you have set a URL to recognize any domain that is dangerous to set up production. This is for local testing only.
I also tried changing the web.xml file in the webapps folder so that these changes remained local, but after several attempts to make it go away, I refused and found that this was due to a global webdefault.