This is a rather short article about an error that we had during the development phase using a test H2 Database.


We have a microservices-based application generated with the help of JHipster which, during development phase, uses an H2 Database to store dummy data.

In one of the microservices we have an invalidation service for the JWT tokens. That is, when a user has his rights elevated (he gets new roles) we need to regenerate the token and invalidate the previous one.

For this to work, we save the tokens in a table. The length of the token is unknown and can become quite large, depending on the information that is stored inside. Therefore, a VARCHAR would not be suitable. Instead, we have created a table with a CLOB type to hold the token.


Below is a snippet containing the declaration of the table in Liquidbase structure:

        <createTable tableName="invalid_token">
            <column name="id" type="bigint" autoIncrement="${autoIncrement}">
                <constraints primaryKey="true" nullable="false"/>
            <column name="token" type="clob">
                <constraints nullable="false" />


On Java side, the Entity looks like this

@Table(name = "invalid_token")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class InvalidToken implements Serializable {
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
    @SequenceGenerator(name = "sequenceGenerator")
    private Long id;
    @Column(name = "token", columnDefinition="CLOB NOT NULL")
    private String token;    
//Getters and setters omitted for brevity

As you can see, the CLOB column is actually a simple String in Java land but annotated with @Lob.

Inside the Spring Boot application, there is a filter which, on every request, checks this table in the database to see if the token is invalid or not.

And everything seems to be working. Until some point.


Problems at the horizon

We noticed that if no request is done to the application for a particular amount of time, usually around 5 minutes, the application will crash with the following exception:

org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(
Caused by: org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: Lob not found: 1/-2"; SQL statement:
select as id1_6_, invalidtok0_.token as token2_6_ from invalid_token invalidtok0_ where invalidtok0_.token=? [50000-197]
    at org.h2.message.DbException.getJdbcSQLException(
    at org.h2.message.DbException.get(
    at org.h2.message.DbException.convert(
    at org.h2.command.Command.executeQuery(
    at org.h2.jdbc.JdbcPreparedStatement.executeQuery(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(
    at com.sun.proxy.$Proxy256.executeQuery(Unknown Source)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(
    ... 133 common frames omitted
Caused by: java.lang.RuntimeException: Lob not found: 1/-2
    at org.h2.message.DbException.throwInternalError(
    at org.h2.value.ValueLobDb.getInputStream(
    at org.h2.value.ValueLobDb.getReader(
    at org.h2.value.ValueLobDb.getString(
    at org.h2.value.ValueLobDb.compareSecure(
    at org.h2.value.Value.compareTo(
    at org.h2.engine.Database.areEqual(
    at org.h2.command.dml.Query.sameResultAsLast(
    at org.h2.command.dml.Query.query(
    at org.h2.command.dml.Query.query(
    at org.h2.command.CommandContainer.query(
    at org.h2.command.Command.executeQuery(
    ... 141 common frames omitted

This happens even with an empty table, so not even with a LOB value inside.


After some troubleshooting and googling I realised that this is not an implementation issue but rather an issue with the underlying H2 mechanism so I begun tinkering with the flags.

If you don’t know, in H2 Database, you can specify configuration flags in the connection URL.

For a spring boot application, this is configured in the (or .yml) under the property spring.datasource.url. Initially, my connection URL was something like this:


In turns out that for a while now H2 has a new storage engine called MvStore. In newer versions this is the default. It can be disabled with a flag mv_store=false.

Because we use H2 database only in devlopment, we don’t actually care if we use a legacy structure or not, so we simply need to append this flag to the connection URL and we are good to go.


I am not sure to which version of H2 this applies, so for completness my version is “1.4.197”.

The version can be queried with



This solved our problems with the LOB missing error.