Re: Weird H2 Database error

856 views
Skip to first unread message

Thomas Mueller

unread,
May 24, 2013, 11:25:18 AM5/24/13
to H2 Google Group
Hi,

The error message "Caused by: java.lang.NoClassDefFoundError: org/h2/engine/Constants " doesn't say much about the state of the database file. All it says is that you have a classloading problem. For example you have multiple version of the H2 jar file in your classpath (at least H2 version 1.3.169 from 2012-09-09, but possibly another one as well).

Regards,
Thomas


On Fri, May 24, 2013 at 5:21 PM, Sammy Guergachi <sguer...@gmail.com> wrote:
So we have a database hosted on a networked drive.

One day I tried to connect to H2 and got this error via the browser tool:

General error: "java.lang.NoClassDefFoundError: org/h2/engine/Constants"; SQL statement:
SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='MODE' [50000-171]
 HY000/50000
org.h2.jdbc.JdbcSQLException: General error: "java.lang.NoClassDefFoundError: org/h2/engine/Constants"; SQL statement:
SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='MODE' [50000-169] 
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:158)
    at org.h2.message.DbException.convert(DbException.java:277)
    at org.h2.command.Command.executeQuery(Command.java:195)
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:308)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NoClassDefFoundError: org/h2/engine/Constants 
    at org.h2.table.MetaTable.generateRows(MetaTable.java:859)
    at org.h2.index.MetaIndex.find(MetaIndex.java:45)
    at org.h2.index.BaseIndex.find(BaseIndex.java:102)
    at org.h2.index.IndexCursor.find(IndexCursor.java:145)
    at org.h2.table.TableFilter.next(TableFilter.java:322)
    at org.h2.command.dml.Select.queryFlat(Select.java:513)
    at org.h2.command.dml.Select.queryWithoutCache(Select.java:618)
    at org.h2.command.dml.Query.query(Query.java:307)
    at org.h2.command.dml.Query.query(Query.java:277)
    at org.h2.command.dml.Query.query(Query.java:36)
    at org.h2.command.CommandContainer.query(CommandContainer.java:86)
    at org.h2.command.Command.executeQuery(Command.java:191)
    ... 3 more 

    at org.h2.engine.SessionRemote.done(SessionRemote.java:568)
    at org.h2.command.CommandRemote.executeQuery(CommandRemote.java:149)
    at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:76)
    at org.h2.server.web.DbContents.readContents(DbContents.java:111)
    at org.h2.server.web.WebApp.tables(WebApp.java:662)
    at org.h2.server.web.WebApp.process(WebApp.java:219)
    at org.h2.server.web.WebApp.processRequest(WebApp.java:164)
    at org.h2.server.web.WebThread.process(WebThread.java:137)
    at org.h2.server.web.WebThread.run(WebThread.java:93)
    at java.lang.Thread.run(Unknown Source) 


I'm pretty new to using H2, and havent been able to find this sort of error anywhere online, so any help as to what the issue might be would be great.
We can't access any of the tables in the database, so it seems corrupted, We have a backup but we would like to make sure this sort of corruption doesn't occur again.

Thanks!

--
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 h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ryan How

unread,
May 24, 2013, 11:34:34 AM5/24/13
to h2-da...@googlegroups.com
I'm seeing 171 on the 2nd line and 169 on the 4th line?

Thomas Mueller

unread,
May 24, 2013, 11:52:47 AM5/24/13
to H2 Google Group
Hi,

Yes, your are right! It's weird that two distinct error codes are in the stack trace (I have never seen that before).

But anyway, it seems like both version 1.3.171 and 1.3.169 are in the classpath.

Regards,
Thomas

Sammy Guergachi

unread,
May 24, 2013, 12:10:07 PM5/24/13
to h2-da...@googlegroups.com
Thanks, it seems I was using 171 jar to view a db created with 169.

I got v169 to open the db and it seems to be fine.

Thanks!

Sammy Guergachi

unread,
May 8, 2014, 4:30:11 PM5/8/14
to h2-da...@googlegroups.com
So I have follow up, I'm having the same issue except it doesn't seem it has anything to do with the using 2 different versions of the H2 jar.

I tried connecting to a database that ran fine but recently stopped working. Its again a NoClassDefFoundError and I have no idea how to fix it, tried many things but I keep getting the same issue:

org.h2.jdbc.JdbcSQLException: General error: "java.lang.NoClassDefFoundError: org/h2/engine/Constants"; SQL statement:
SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='MODE' [50000-171] 

I checked my environment variables and found no CLASSPATH but am still able to run other Java applications, so I don't know how I can rectify the issue if its due to the classpath.

The super weird thing is i've tried moving the database to a different location and connect to it there to see if that would make any difference and found that I was able to connect with no issues. I cut and past the database to a different location and try and access it there its fine but if I cut and paste it back to its original "corrupted" location it gives me the exception only after I connect (I tried using the Test Connection button and always get "Test successful") 

This leaves me puzzled, how can there be an issue with connecting with a database at one specific location, but any other location is fine. I have no idea where to start looking to fix this issue.

Thanks again!

Sammy Guergachi

unread,
May 8, 2014, 4:30:53 PM5/8/14
to h2-da...@googlegroups.com
This is the full error output just in case:


org.h2.jdbc.JdbcSQLException: General error: "java.lang.NoClassDefFoundError: org/h2/engine/Constants"; SQL statement:
SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='MODE' [50000-171] 

    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:158)
    at org.h2.message.DbException.convert(DbException.java:277)
    at org.h2.command.Command.executeQuery(Command.java:195)
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:309)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:150)

    at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NoClassDefFoundError: org/h2/engine/Constants 
    at org.h2.table.MetaTable.generateRows(MetaTable.java:860)
    at org.h2.index.MetaIndex.find(MetaIndex.java:45)
    at org.h2.index.BaseIndex.find(BaseIndex.java:103)

    at org.h2.index.IndexCursor.find(IndexCursor.java:145)
    at org.h2.table.TableFilter.next(TableFilter.java:322)
    at org.h2.command.dml.Select.queryFlat(Select.java:517)
    at org.h2.command.dml.Select.queryWithoutCache(Select.java:622)
    at org.h2.command.dml.Query.query(Query.java:311)
    at org.h2.command.dml.Query.query(Query.java:281)

    at org.h2.command.dml.Query.query(Query.java:36)
    at org.h2.command.CommandContainer.query(CommandContainer.java:86)
    at org.h2.command.Command.executeQuery(Command.java:191)
    ... 3 more 

    at org.h2.engine.SessionRemote.done(SessionRemote.java:568)
    at org.h2.command.CommandRemote.executeQuery(CommandRemote.java:149)
    at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:76)
    at org.h2.server.web.DbContents.readContents(DbContents.java:111)
    at org.h2.server.web.WebApp.tables(WebApp.java:662)
    at org.h2.server.web.WebApp.process(WebApp.java:219)
    at org.h2.server.web.WebApp.processRequest(WebApp.java:164)
    at org.h2.server.web.WebThread.process(WebThread.java:137)
    at org.h2.server.web.WebThread.run(WebThread.java:93)
    at java.lang.Thread.run(Unknown Source) 

Sammy Guergachi

unread,
May 8, 2014, 5:04:20 PM5/8/14
to h2-da...@googlegroups.com
It also seems that when I'm trying to access the VALUES column from within the client as opposed to the console (which is how I accessed it above) I get this error:

org.h2.jdbc.JdbcSQLException: Connection is broken: "unexpected status 805318656" [90067-171]

And that's only for the VALUES column, every column accessed before or after it returns the correct values. 

Noel Grandin

unread,
May 9, 2014, 3:04:38 AM5/9/14
to h2-da...@googlegroups.com

If you're getting NoClassDefFoundError, then you have multiple versions of H2 on your classpath.

Check
(a) your CLASSPATH, and
(b) if you have any linked jars from your current jars that reference the H2 library in their MANIFEST
(c) if you have any merged jars lying around that include H2 inside themselves.

Sammy Guergachi

unread,
May 9, 2014, 10:56:37 AM5/9/14
to h2-da...@googlegroups.com
I tried looking everywhere and they all use 1.3.171. Also I don't see how multiple versions of h2 would explain *moving* the .h2.db file to a different folder and accessing it there with the same setup fixing the issue.

I need to mention that the db is on a networked drive and being accessed by multiple computers with Auto Server mode enabled. I also have to restate that I get a connection broken (error code 90067) in the actual java application and a NoClassDefFoundError in the console.

Something else I noticed today was that I wasn't able to delete the .lock (as it reappeared from a user still connected) and .trace files (locked unable to delete) in the original, problematic, location of the db. I suspect that this issue has something to do with those 2 files. 

Noel Grandin

unread,
May 11, 2014, 9:50:20 AM5/11/14
to h2-da...@googlegroups.com
On Fri, May 9, 2014 at 4:56 PM, Sammy Guergachi <sguer...@gmail.com> wrote:
> I tried looking everywhere and they all use 1.3.171. Also I don't see how
> multiple versions of h2 would explain *moving* the .h2.db file to a
> different folder and accessing it there with the same setup fixing the
> issue.
>
'> I need to mention that the db is on a networked drive and being accessed by
> multiple computers with Auto Server mode enabled. I also have to restate
> that I get a connection broken (error code 90067) in the actual java
> application and a NoClassDefFoundError in the console.
>

Because when you moved it, the machine that was running with multiple
versions of H2 was no longer trying to act as the server?

Seems pretty obvious to me that you have a machine somewhere still
running with multiple versions of H2 in it's classpath.

Sammy Guergachi

unread,
May 12, 2014, 9:46:54 AM5/12/14
to h2-da...@googlegroups.com
Hmm, ok, I will have to track down the computer with the ip in the .lock file then. Thanks.

Thomas Mueller

unread,
May 12, 2014, 12:52:44 PM5/12/14
to H2 Google Group
Hi,

Yes, NoClassDefFoundError is a clear sign that something is wrong with the classpath. This needs to be resolved.

Regards,
Thomas


--
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 h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages