Permission denied at temp file creation

1,241 views
Skip to first unread message

pepez

unread,
Sep 30, 2008, 5:42:57 AM9/30/08
to H2 Database
Hi!

We have a following problem happening only on linux environment. The
H2 version is 1.0.78 and we are using in-memory DB.

Where H2 tries to create this temp file by default and is it somehow
configurable?

Thank you!

Caused by: org.h2.jdbc.JdbcSQLException: IO Exception:
java.io.IOException: Permission denied; mem:appDB[90031-78]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.convertIOException(Message.java:271)
at org.h2.engine.SessionRemote.createTempFile(SessionRemote.java:459)
at org.h2.value.ValueLob.initLarge(ValueLob.java:375)
at org.h2.value.ValueLob.createFromReader(ValueLob.java:201)
at org.h2.value.ValueLob.createClob(ValueLob.java:169)
at org.h2.jdbc.JdbcConnection.createClob(JdbcConnection.java:1500)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
945)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
917)
at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setCharacterStream(WrappedPreparedStatement.java:
491)
at org.hibernate.type.TextType.set(TextType.java:22)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:
307)
at
org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:
755)
at
org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:
1143)
... 38 more
Caused by: java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1793)
at org.h2.store.fs.FileSystemDisk.createTempFile(FileSystemDisk.java:
157)
at org.h2.util.FileUtils.createTempFile(FileUtils.java:158)
at org.h2.engine.SessionRemote.createTempFile(SessionRemote.java:457)
... 51 more
Message has been deleted

Thomas Mueller

unread,
Oct 1, 2008, 4:34:50 PM10/1/08
to h2-da...@googlegroups.com
Hi,

I can reproduce this problem with previous versions, but so far I
couldn't reproduce it with version 1.0.78. Could you post a simple
test case similar to the one below? Or maybe this test doesn't work
for you?

public static void main(String[] args) throws Exception {
org.h2.Driver.load();
Server server = Server.createTcpServer(new String[0]).start();
Connection conn =
DriverManager.getConnection("jdbc:h2:tcp://localhost/mem:appDB");
System.out.println(conn.getMetaData().getDatabaseProductVersion());
PreparedStatement prep = conn.prepareStatement("CALL ?");
prep.setCharacterStream(1, new StringReader(new String(new
char[100000])));
prep.executeQuery();
conn.close();
server.stop();
}

Regards,
Thomas

pepez

unread,
Oct 2, 2008, 5:21:41 AM10/2/08
to H2 Database
Here is the output of the test (Java 1.6.0_06, Ubuntu 8.04, 2.6.24-19-
generic):

1.0.78 (2008-08-28)
Exception in thread "main" org.h2.jdbc.JdbcSQLException: IO Exception:
java.io.IOException: Permission denied; mem:appDB [90031-78]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.convertIOException(Message.java:271)
at org.h2.engine.SessionRemote.createTempFile(SessionRemote.java:459)
at org.h2.value.ValueLob.initLarge(ValueLob.java:375)
at org.h2.value.ValueLob.createFromReader(ValueLob.java:201)
at org.h2.value.ValueLob.createClob(ValueLob.java:169)
at org.h2.jdbc.JdbcConnection.createClob(JdbcConnection.java:1500)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
945)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
917)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
928)
at H2Test.main(H2Test.java:17)
Caused by: java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1793)
at org.h2.store.fs.FileSystemDisk.createTempFile(FileSystemDisk.java:
157)
at org.h2.util.FileUtils.createTempFile(FileUtils.java:158)
at org.h2.engine.SessionRemote.createTempFile(SessionRemote.java:457)
... 8 more


On Oct 1, 9:34 pm, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:

pepez

unread,
Oct 2, 2008, 5:25:53 AM10/2/08
to H2 Database
And same with the latest:

1.0.79 (2008-09-26)
Exception in thread "main" org.h2.jdbc.JdbcSQLException: IO Exception:
java.io.IOException: Permission denied; mem:appDB [90031-79]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.convertIOException(Message.java:271)
at org.h2.engine.SessionRemote.createTempFile(SessionRemote.java:459)
at org.h2.value.ValueLob.initLarge(ValueLob.java:375)
at org.h2.value.ValueLob.createFromReader(ValueLob.java:201)
at org.h2.value.ValueLob.createClob(ValueLob.java:169)
at org.h2.jdbc.JdbcConnection.createClob(JdbcConnection.java:1521)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
945)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
917)
at
org.h2.jdbc.JdbcPreparedStatement.setCharacterStream(JdbcPreparedStatement.java:
928)
at H2Test.main(H2Test.java:17)
Caused by: java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1793)
at org.h2.store.fs.FileSystemDisk.createTempFile(FileSystemDisk.java:
157)
at org.h2.util.FileUtils.createTempFile(FileUtils.java:158)
at org.h2.engine.SessionRemote.createTempFile(SessionRemote.java:457)
... 8 more


pepez

unread,
Oct 2, 2008, 6:11:38 AM10/2/08
to H2 Database
Hi Thomas,

Under linux the System.getProperty("java.io.tmpdir") returns /tmp
without trailing path separator '/' character which is different from
Windows (....\LOCALS~1\Temp\). This most likely causes the problem in
getFilePrefix method in SessionRemote class as the database name is
appended after the directory string.

Thomas Mueller

unread,
Oct 3, 2008, 5:16:11 AM10/3/08
to h2-da...@googlegroups.com
Hi,

Thanks! You are right, the missing slash is the problem. Unfortunately
I did not test the last release with Linux, otherwise I would have
found out. The fix is:

SessionRemote.getFilePrefix(String dir) {
StringBuffer buff = new StringBuffer();
buff.append(dir);
buff.append('/'); // << NEW

This will be fixed in the next release.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages