FileNotFoundException in version 1.1.118

48 views
Skip to first unread message

ccwhk

unread,
Dec 18, 2009, 3:10:01 AM12/18/09
to H2 Database
We are using H2 version 1.1.118 (latest stable) in embeded mode with
TCP allow option for remote access.

We experienced a FileNotFoundException while we are running the
application with the embedded database in Red Hat Linux Enterprise
Edition. We use CLOB to save XML message in our database.

We found that the path of the DB files is not correct. The correct
path should be /home/mtsbprod/im.trace.db instead of /home/
mtsbprodim.trace.db. There is a slash "/" missing in the file path.

I noted following in version 1.1.119's change log:

"Updating many rows with the same CLOB or BLOB values could result in
FileNotFoundException."

Will version 1.1.119 fix our problem?

If so, will there be any separate patch of 1.1.118 for this issue
since we feel that the current latest H2 release is not very stable
starting from version 1.1.119?


Below is the log of our exception.

org.h2.jdbc.JdbcSQLException: Log file error: /home/
mtsbprodim.trace.db, cause: org.h2.jdbc.JdbcSQLException: IO
Exception: java.io.FileNotFoundException: /home/mtsbprodim.trace.db
(Permission denied); /home/mtsbprodim.trace.db [90031-118] [90034-118]
org.h2.jdbc.JdbcSQLException: Log file error: /home/
mtsbprodim.trace.db, cause: org.h2.jdbc.JdbcSQLException: IO
Exception: java.io.FileNotFoundException: /home/mtsbprodim.trace.db
(Permission denied); /home/mtsbprodim.trace.db [90031-118] [90034-118]
at org.h2.message.Message.getSQLException(Message.java:105)
at org.h2.message.TraceSystem.logWritingError(TraceSystem.java:287)
at org.h2.message.TraceSystem.openWriter(TraceSystem.java:306)
at org.h2.message.TraceSystem.<init>(TraceSystem.java:112)
at org.h2.engine.Database.open(Database.java:557)
at org.h2.engine.Database.openDatabase(Database.java:220)
at org.h2.engine.Database.<init>(Database.java:215)
at org.h2.engine.Engine.openSession(Engine.java:58)
at org.h2.engine.Engine.openSession(Engine.java:140)
at org.h2.engine.Engine.getSession(Engine.java:120)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:122)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception:
java.io.FileNotFoundException: /home/mtsbprodim.trace.db (Permission
denied); /home/mtsbprodim.trace.db [90031-118]
at org.h2.message.Message.getSQLException(Message.java:105)
at org.h2.message.Message.convertIOException(Message.java:292)
at org.h2.store.fs.FileSystemDisk.openFileOutputStream
(FileSystemDisk.java:353)
at org.h2.util.FileUtils.openFileOutputStream(FileUtils.java:241)
at org.h2.message.TraceSystem.openWriter(TraceSystem.java:303)
... 9 more
Caused by: java.io.FileNotFoundException: /home/mtsbprodim.trace.db
(Permission denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at org.h2.store.fs.FileSystemDisk.openFileOutputStream
(FileSystemDisk.java:345)
... 11 more

Thomas Mueller

unread,
Dec 18, 2009, 1:40:12 PM12/18/09
to h2-da...@googlegroups.com
Hi,

> We experienced a FileNotFoundException

Yes, but you also got "Permission denied" in the exception.

> We found that the path of the DB files is not correct. The correct
> path should be /home/mtsbprod/im.trace.db instead of /home/
> mtsbprodim.trace.db. There is a slash "/" missing in the file path.

That sounds serious. What database URL do you use?

> "Updating many rows with the same CLOB or BLOB values could result in
> FileNotFoundException."
> Will version 1.1.119 fix our problem?

Currently, I don't think that's the problem. Your exception is not
related to CLOB or BLOB. The exception occurs for the .trace.db file
(trace output).

Regards,
Thomas

ccwhk

unread,
Dec 20, 2009, 9:11:54 PM12/20/09
to H2 Database
The DB URL is jdbc:h2:~/im;DB_CLOSE_ON_EXIT=FALSE and we use the user
account mtsbprod to run the application in Linux.

Thus, H2 engine really misses one slash "/" under certain conditions.

Since we had deployed the application with H2 version 1.1.118 for more
than 3 months and such exception only occurred once.

FYI, we had some very large XML stored in the DB as CLOB (1-2MB).


On 12月19日, 上午2時40分, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

Thomas Mueller

unread,
Dec 21, 2009, 8:40:36 AM12/21/09
to h2-da...@googlegroups.com
Hi,

> The DB URL is "jdbc:h2:~/im;DB_CLOSE_ON_EXIT=FALSE

Are you sure? The exception you posted indicates the problem occurred
when using the server mode. However when using the server mode, the
URL must start with jdbc:h2:tcp://... or jdbc:h2:ssl://

I can reproduce the problem when using the database URL jdbc:h2:~im
(missing the "/"). The URL jdbc:h2:~/im it works for me. Reading the
source code, that would be the only explanation I can find. There are
only two places in H2 where ~ is converted to the user home directory
(that's one place too much, anyway), and it is done as follows:

if (fileName.startsWith("~")) {
String userDir = SysProperties.USER_HOME;
fileName = userDir + fileName.substring(1);
}

I will change the code so only "~", "~/..." and "~\..." are accepted.

> So far, such error only exists recently for one and only one time.

Maybe the '/' is not appended in some cases when using the server mode
(not sure). Could you check if the database URL is different? Or (even
better) could you create a simple reproducible test case?

Regards,
Thomas

ccwhk

unread,
Dec 21, 2009, 12:06:09 PM12/21/09
to H2 Database
The path (jdbc:h2:~/im;DB_CLOSE_ON_EXIT=FALSE) is correct because the
application will start the DB in embedded mode with the TCP option
turned on as follows in a spring environment:

<bean id = "org.h2.tools.Server"
class="org.h2.tools.Server"
factory-method="createTcpServer"
init-method="start"
destroy-method="stop">
<constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" /
>
</bean>

In such case, the application will start the DB by itself while other
people can access the DB data using the H2 console tools remotely in a
browser.

Thank you very much for your prompt reply.

On 12月21日, 下午9時40分, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

Thomas Mueller

unread,
Dec 23, 2009, 8:21:53 AM12/23/09
to h2-da...@googlegroups.com
Hi,

> the application will start the DB in embedded mode with the TCP option
> turned on as follows in a spring environment:

OK, then what is the database URL that is used by those clients that
connect over TCP?

>> I can reproduce the problem when using the database URL jdbc:h2:~im
>> (missing the "/").

> while other people can access the DB data using the H2 console tools remotely in a browser.

The TCP server doesn't allow browser connections. For browser
connections, you need to start the H2 Console (-web, not -tcp).

The stack trace you sent includes a TCP connection. So my best guess
currently is that one of those other users used a database URL:
jdbc:h2:tcp://..../~im

If this is not the problem, could you please provide a reproducible test case?

Regards,
Thomas

ccwhk

unread,
Dec 23, 2009, 10:01:01 PM12/23/09
to H2 Database
Thank you for your help.

> The stack trace you sent includes a TCP connection. So my best guess
> currently is that one of those other users used a database URL:
> jdbc:h2:tcp://..../~im

For this question, I need to further confirm with my users. So please
ignore this problem at the time being.

Furthermore, below are the details about our usage of H2. Are the
below configuration and usage appropriate?

Our spring application will start H2 Server in Red Hat Linux with the
below configuration:

<bean id = "org.h2.tools.Server"
class="org.h2.tools.Server"
factory-method="createTcpServer"
init-method="start"
destroy-method="stop">
<constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" /
>
</bean>

Yet, in that application, there will be a thread connecting the H2 DB
using "jdbc:h2:~/im;DB_CLOSE_ON_EXIT=FALSE".

Should we use the url "jdbc:h2:tcp://<IP>:<Port>/~/im" instead?

Furthermore, we will use the URL "jdbc:h2:tcp://<IP>:<Port>/~/im" for
accessing (mainly query the DB table) the H2 DB by the H2 console in a
web browser remotely.

We start the H2 console by running the default batch file "h2.bat" in
WINDOW XP, which will automatically start a browser, allowing us to
view data remotely in the browser.


On 12月23日, 下午9時21分, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

Thomas Mueller

unread,
Dec 27, 2009, 10:52:21 AM12/27/09
to h2-da...@googlegroups.com
Hi,

> Are the below configuration and usage appropriate?

> <bean id = "org.h2.tools.Server"


>            class="org.h2.tools.Server"
>            factory-method="createTcpServer"
>            init-method="start"
>            destroy-method="stop">
>    <constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" /

Yes, except for: -tcp,-tcpAllowOthers,true,-tcpPort,8043 - you can
remove the 'true' in version 1.1.x or newer, so you can write:
-tcp,-tcpAllowOthers,-tcpPort,8043

> Yet, in that application, there will be a thread connecting the H2 DB
> using  "jdbc:h2:~/im;DB_CLOSE_ON_EXIT=FALSE".
> Should we use the url "jdbc:h2:tcp://<IP>:<Port>/~/im" instead?

No, if you are using the embedded mode (which is faster) then that's OK.

> Furthermore, we will use the URL "jdbc:h2:tcp://<IP>:<Port>/~/im" for
> accessing (mainly query the DB table) the H2 DB by the H2 console in a
> web browser remotely.

Yes, that's correct.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages