我有一个 GWT Web 应用程序,它在磁盘上的相对目录“缓存”下创建一个缓存。在我在 Eclipse 中的 JUnit 测试中它可以工作,但是当我在 Tomcat 中部署它时,程序仍然尝试在/home/username/projects/myproject/cache
(重命名的真实路径)中创建文件,而不是/var/lib/tomcat7/webapps/myproject/cache
因为它在那里没有文件写访问权限,所以它崩溃了。创建缓存的代码是一个外部库,因此它甚至不能被硬编码。
它可能是一个符号链接吗?或者Tomcat和Eclipse可以共享一个JVM吗?这个错误让我发疯。
错误信息
org.h2.jdbc.JdbcSQLException: Fehler beim Erzeugen der Datei "/home/username/projects/myproject/cache"
Error while creating file "/home/username/projects/myproject/cache" [90062-143]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.store.fs.FileSystemDisk.createDirs(FileSystemDisk.java:368)
at org.h2.store.FileLock.lockFile(FileLock.java:328)
at org.h2.store.FileLock.lock(FileLock.java:134)
at org.h2.engine.Database.open(Database.java:525)
at org.h2.engine.Database.openDatabase(Database.java:208)
at org.h2.engine.Database.<init>(Database.java:203)
at org.h2.engine.Engine.openSession(Engine.java:53)
at org.h2.engine.Engine.openSession(Engine.java:147)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:126)
at org.h2.engine.Engine.createSession(Engine.java:109)
at org.h2.engine.Engine.createSession(Engine.java:27)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:289)
at org.h2.engine.SessionRemote.createSession(SessionRemote.java:265)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:73)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
[...]