glenrobson / SimpleAnnotationServer

A simple IIIF and Mirador compatible Annotation Server
Apache License 2.0
97 stars 28 forks source link

Problem showing 12 or more tagged annotations in Mirador #32

Closed thanneken closed 6 years ago

thanneken commented 6 years ago

I'm not sure if this is a concern with Simple Annotation Server or Mirador, but I thought I would start here.

I have Simple Annotation Server (mirador 2.1.4 branch) working well with Mirador 2.6.1, at least for the first few annotations. The problem is that after 12 or more tagged annotations on the same canvas are stored in Simple Annotation Server they all disappear in the next browser session. By next browser session, I mean it appears to keep working but if I close the browser and start again, the annotations do not appear in Mirador. The annotations are still there in SimpleAnnotationServer (they appear in the JSON returned from :8888/annotation/).

The simplest recreation of the problem involved going to a canvas and adding 13 annotations. At that point it still worked, even in a new browser session. Then I added tags to all 13 annotations, and they did not appear in the next browser session.

The short-term solution has been to move annotations from Simple Annotation Server to static json files (no data was lost).

My annotation server is at http://35.162.52.109:8888/annotation/ The Mirador instance is at http://jubilees.stmarytx.edu/mirador/ The test page is the third canvas on "Jubilees Palimpsest Project, Milan 2017" (not sure of the best way to link directly until I borrow the javascript from Durham)

glenrobson commented 6 years ago

It looks like a CORS issue, you have the following in the console:

The Same Origin Policy disallows reading the remote resource at http://35.162.52.109:8888/annotation/search?uri=http%3A%2F%2Fjubilees.stmarytx.edu%2Fiiifp%2FMilanWinter2017%2Fcanvas%2FGroup&APIKey=user_auth&media=image&limit=10000&_=1520515254884

I'm not sure why this would kick in after 13 annotations but will look into it.

thanneken commented 6 years ago

I was able to achieve functionality by moving to Tomcat 9 and editing the file $CATALINA_HOME/webapps/simpleAnnotationStore/WEB-INF/web.xml I replaced the line <filter-class>uk.org.llgc.annotation.store.filters.CorsFilter</filter-class> with <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>

The command curl -H "Origin: http://jubilees.stmarytx.edu" --head http://35.162.52.109:8888/simpleAnnotationStore/ now returns a line that reads: Access-Control-Allow-Origin: http://jubilees.stmarytx.edu whereas before I believe the equivalent line read: Access-Control-Allow-Origin: *

I don't understand what is going on here but hope it will be helpful to others.

glenrobson commented 6 years ago

Thanks thats great news you have a work around. I'm afraid I haven't had chance to look at what is causing the issue in SAS.

glenrobson commented 6 years ago

I couldn't recreate this issue but I've hopefully fixed the cause error in the following commit:

https://github.com/glenrobson/SimpleAnnotationServer/commit/320189a9a673ab12a6eaaff5308ba56f8eabcfe1