If you see these errors occurring, this is generally caused by the following reasons. This guide will walk you through the debugging process to identify the specific problem and how to remedy the issue.
- The application.conf file is incorrect. Please go back and follow the steps listed in the installation guide. This is the most common problem - often the origins are specified without the port numbers and this can cause things to fail, eg: use 'http://localhost:8080' instead of 'http://localhost'. After making changes to the application.conf file, please restart Tomcat .
- The application.conf file is correct, but something is wrong with one of the services. See the section below to debug the services
- The application.conf file is correct, and the services are working, but the URL's that editor uses are not quite right. Refer to this config page for help
- All of the above are correct, but the browser sends back a different origin. See step 6. of 'Using Browser Tooling to Investigate Services Issues' below and add the origin value to the list of origins. Restart Tomcat and then refresh the editor page in a browser and things should work.
Checking the Server Configuration
To test the services, we will start with the following:
We will use Tomcat 7 installed at /opt/tomcat/ and running on port 8080, and this is our 'application.conf' file. We have made a folder called 'images' in the webapps directory of the tomcat install i.e. /opt/tomcat/webapps/images/. Some of the commands below that require a 'terminal' window to be used.
If you are on a Linux or Mac environment use a shell of your choice and make sure the 'curl' package is installed.
If you are on a windows environment follow the page Installing curl in Windows and then open a 'cmd' prompt and run the commands from there.
Please modify your configuration according to how you have it set up based on your environment.
ephox{ allowed-origins { origins = [ "http://localhost", "http://localhost:8080", "http://myserver" ] url = "http://localhost:8080/ephox-allowed-origins/cors" } image-proxy { storageURL = "http://localhost:8080/ephox-local-storage/api/1/storeImage" } local-storage { imagesDirectory = "/opt/tomcat7/webapps/images/" returnUrl = "http://localhost:8080/images/" } }
Lets start with the 'ephox-allowed-origins'
Once you've deployed the service and started Tomcat/Jetty open a browser window and enter the following:
http://localhost:8080/ephox-allowed-origins/cors
This should return the entire list of origins that you specified in the application.conf file. So you should see the following returned, if everything is working correctly. If you see only one or do not see this altogether, then Tomcat hasn't been configured correctly to use the application.conf file. Refer to step 3 of the Installing Services Section to fix this and make sure you can see the response below before proceeding
{"value":["http://localhost", "http://localhost:8080", "http://myserver"]}
Debugging 'ephox-spelling'
Once you've deployed the service and started Tomcat/Jetty open a browser window and enter the following:
http://localhost:8080/ephox-spelling/version
This should return the version number "1.1.0"
Now open a terminal window and enter the following to test that the dictionaries are loaded correctly and the service is responding as intended. Note: the "Origin" value specifies the origin that the request is originating from - in a browser with the editor loaded this happens automatically
curl -v --request POST -H "Content-Type: application/json" -H "Origin: http://localhost:8080" http://localhost:8080/ephox-spelling/1/suggestion -d '{ "words":["hello","world"], "language": "en_US" }'
If you are using Windows and curl, please make sure you add escape characters ("\") to the quotes and use double quotes (") around the data parameter, instead of single quotes (') as shown below
curl -v --request POST -H "Content-Type: application/json" -H "Origin: http://localhost:8080" http://localhost:8080/ephox-spelling/1/suggestion -d "{ \"words\":[\"hello\",\"world\"], \"language\": \"en_US\" }"
The response below is what you should see. The example below is good and returns a status code 200. If you see a error code 403, that means the value of the "Origin " supplied is incorrect. Please edit the list of origins in the 'application.conf' file and restart Tomcat7.
* Hostname was NOT found in DNS cache * Trying w.x.y.z... * Connected to localhost (w.x.y.z) port 8080 (#0) > POST /ephox-spelling/1/suggestion HTTP/1.1 > User-Agent: curl/7.35.0 > Host: localhost:8080 > Accept: */* > Content-Type: application/json > Origin: http://localhost:8080 > Content-Length: 64 > * upload completely sent off: 64 out of 64 bytes * HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Access-Control-Allow-Credentials: true < Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS < Access-Control-Allow-Origin: http://localhost:8080 < Access-Control-Max-Age: 3600 < Content-Type: application/json;charset=UTF-8 < Date: Tue, 25 Nov 2014 23:34:09 GMT < Content-Length: 302 < Connection: close < * Closing connection 0 {"suggest":{"hello":["hello","hellos","hell","helot","hellion","helloed","helloes","jello","halo","shell","he'll","he´ll","helots","hallow","hollow","halloo"],"world":["world","worlds","word","wold","worldly","whorled","sword","whorl","wordy","words","old","would","worked","ward","swords","whorls"]}}
Once you see that the service is responding with the correct response, the next steps are to check the data that the browser is sending to the service.
Related articles