It was working fine, but after I rebooted the server, tomcat started to give me this error every time the JSP tries to insert something into the SQLite database in question. However, any kind of read operation works fine.
javax.servlet.ServletException: org.sqlite.SQLiteException:
[SQLITE_READONLY] Attempt to write a readonly database (attempt to write a readonly database)
The database file was located at /var/lib/tomcat9/dbs/something.db
and the following is permission, user:group for those directory and file.
/var/lib/tomcat9/dbs
:775
tomcat:tomcat
something.db
:644
tomcat:tomcat
Before the reboot, I had no problem with this setup, but after the reboot, I always get an error. I tried the following and nothing fixed the issue.
- change the permission to
777
for both/var/lib/tomcat9/dbs
andsomething.db
- add the following lines to the java connector class before it tries to make a connection
SQLiteConfig config = new SQLiteConfig();
config.setReadOnly(false);
Any ideas on why and how to fix this issue?
So far the only working solution I found was moving the file to <NAME_OF_MY_APP>/src/main/webapp/WEB-INF/sql/something.db
so that the db file could be ended up on /var/lib/tomcat9/webapps/<NAME_OF_MY_APP>/WEB-INF/sql
after the war file deployment and the change the resource url on context.xml
accordingly. Is this something okay to do? If not, what's the alternative?