Persistent principals across restarts of the the application:

The principal is not stored across restarts of the application, and therefore the WebSpeechRecorderNg  cannot store pending recording uploads.

This may work starting with Tomcat 8.5.53 or 9.0.32

https://tomcat.apache.org/tomcat-8.5-doc/config/manager.html

See attribute persistAuthentication

and 
https://tomcat.apache.org/tomcat-8.5-doc/config/manager.html#Persistence_Across_Restarts

Unfortunately Ubuntu 18.04 and 20.04 use an older version.

Ubuntu 22.04 will have tomcat9 (9.0.58-1)



Locking:

Required for Entities:

Session: SpeechRecorder patches Session object.
RecordingFile: Selection editing

For stateless REST only optimistic locking is recommended:

Compare ETag in If-Match header before saving the change.
https://sookocheff.com/post/api/optimistic-locking-in-a-rest-api/ 

In JAX-RS:
https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Request.html

Response.ResponseBuilder 	evaluatePreconditions(EntityTag eTag)

(or use Date lastModified or both ?)

Pessimistic locking might be better in certain cases.
Maybe on "application level":
Entity properties
lockedBy and lockedAt

or use status property.

Problems: Deadlocks. In our case prevent by binding the lock to the HTTP session.

Links:

https://stackoverflow.com/questions/129329/optimistic-vs-pessimistic-locking
https://softwareengineering.stackexchange.com/questions/287625/is-rest-only-limited-to-optimistic-concurrency-control
https://medium.com/swlh/api-concurrency-control-strategies-cd546c2cdc16
https://stackoverflow.com/questions/30080634/concurrency-in-a-rest-api
https://de.wikipedia.org/wiki/HTTP_ETag
