See also this StackOverflow question
<http://stackoverflow.com/questions/41293469/h2-database-in-tomcat-environment-throwing-runtimeexception-unexpected-code-pat>
I am using H2 database h2-1.4.193 as datasource in tomcat.
This is my server.xml entry:
<Resource auth="Container"
driverClassName="org.h2.Driver"
logAbandoned="true"
maxIdle="10"
maxOpenPreparedStatements="5"
maxTotal="50"
maxWaitMillis="10000"
name="jdbc/shopfloor_local"
password="***" poolPreparedStatements="false"
removeAbandonedOnBorrow="true" removeAbandonedOnMaintenance="true"
removeAbandonedTimeout="180" scope="Shareable" testWhileIdle="true"
timeBetweenEvictionRunsMillis="600000" type="javax.sql.DataSource"
url="jdbc:h2:~/shopfloor;AUTO_SERVER=TRUE;TRACE_LEVEL_SYSTEM_OUT=3"
username="SA"
validationQuery="select 1"/>
I use this datasource for both the DataSourceRealm and my application. In
my application I execute a select on a sequence:
select aufgabenliste_seq.nextval
and then I get this error:
2016-12-23 00:46:03 jdbc[3]: /**/conn3.setAutoCommit(false);2016-12-23 00:46:03
jdbc[3]: /**/PreparedStatement prep8 = conn3.prepareStatement("select
aufgabenliste_seq.nextval");2016-12-23 00:46:03 jdbc[3]: Plan : calculate
cost for plan [SYSTEM_RANGE:0:org.h2.table.RangeTable@603d6c40]2016-12-23
00:46:03 jdbc[3]: Plan : for table filter
SYSTEM_RANGE:0:org.h2.table.RangeTable@603d6c402016-12-23 00:46:03 jdbc[3]:
Table : potential plan item cost 1 index PUBLIC.RANGE_INDEX2016-12-23
00:46:03 jdbc[3]: Plan : best plan item cost 1 index
PUBLIC.RANGE_INDEX2016-12-23 00:46:03 jdbc[3]: Plan : plan cost
22016-12-23 00:46:03 jdbc[3]: /**/ResultSet rs9 =
prep8.executeQuery();2016-12-23 00:46:03 lock: 1 exclusive write lock
requesting for SYS2016-12-23 00:46:03 lock: 1 exclusive write lock added for
SYS2016-12-23 00:46:03 lock: 1 exclusive write lock unlock SYS2016-12-23
00:46:03 lock: 1 exclusive write lock requesting for SYS2016-12-23 00:46:03
lock: 1 exclusive write lock added for SYS2016-12-23 00:46:03 jdbc[3]: exception
org.h2.jdbc.JdbcSQLException: Allgemeiner Fehler: "java.lang.RuntimeException:
Unexpected code path"General error: "java.lang.RuntimeException: Unexpected
code path"; SQL statement:
select aufgabenliste_seq.nextval [50000-193]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:295)
at org.h2.command.Command.executeQuery(Command.java:213)
at
org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:110)
at
org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)
at
org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)......Caused
by: java.lang.RuntimeException: Unexpected code path
at org.h2.message.DbException.throwInternalError(DbException.java:242)
at org.h2.message.DbException.throwInternalError(DbException.java:255)
at org.h2.engine.Session.addLock(Session.java:842)
at org.h2.mvstore.db.MVTable.doLock2(MVTable.java:254)
at org.h2.mvstore.db.MVTable.doLock1(MVTable.java:202)
at org.h2.mvstore.db.MVTable.lock(MVTable.java:167)
at org.h2.engine.Database.lockMeta(Database.java:909)......
I have debugged into the code. The Exception is thrown in Session class in
Method addLock():
public void addLock(Table table) {
if (SysProperties.CHECK) {
if (locks.contains(table)) {
DbException.throwInternalError();
}
}
locks.add(table);
}
The table object to be logged contains the table SYS.
Why is requesting the lock of SYS failing in this case? Should I provide
additional parameters to the connection string?
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.