akarshan2701 / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

NullPointerException in ValueInt while closing Database #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. Use H2 in Tomcat.
2. Restart or Hotdeploy Tomcat within Eclipse IDE
3. Exception (see below) occurs everytime Tomcat is trying to shut down

What is the expected output? What do you see instead?
No output at all is expected. Instead, the following exception occurs:
Exception in thread "Thread-5" java.lang.NullPointerException
    at org.h2.value.ValueInt.get(ValueInt.java:62)
    at org.h2.engine.Database.removeMeta(Database.java:785)
    at org.h2.engine.Database.update(Database.java:1354)
    at org.h2.schema.Sequence.flush(Sequence.java:125)
    at org.h2.schema.Sequence.close(Sequence.java:142)
    at org.h2.engine.Database.close(Database.java:1082)
    at org.h2.engine.DatabaseCloser.run(DatabaseCloser.java:75)

What version of the product are you using? On what operating system, file
system, and virtual machine?
v1.1.102 on Win2000 within Eclipse IDE running a Java WebApp within Tomcat 5.5

Do you know a workaround?
No

How important/urgent is the problem for you?
Low, as it only happens at shutdown

In your view, is this a defect or a feature request?
Defect. A NPE is very likely to be a defect :-)

Please provide any additional information below.

Datasource configuration in Spring ApplicationContext:
   <bean id="H2InMemoryDB"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="org.h2.Driver" />
      <property name="url" value="jdbc:h2:db_h2;AUTO_RECONNECT=TRUE" />
      <property name="username" value="sa" />
      <property name="password" value="" />
   </bean>

Thanks for H2 anyway, it's a really cool product and I love to use it for
demoing software and for unit testing purposes. We're integrating it in a
finance solution.

Original issue reported on code.google.com by jupl...@gmail.com on 10 Nov 2008 at 9:07

GoogleCodeExporter commented 8 years ago
I'm not sure if this problem can be solved in H2. The NullPointerException 
occurs in
ValueInt, line 62:

return staticCache[i];

So 'staticCache' must be null. However, this field is static and initialized 
when
loading the class:

private static ValueInt[] staticCache;

private static ValueInt[] dynamicCache;
static {
  staticCache = new ValueInt[STATIC_SIZE];
  ...
}

So in theory this field can never become null. However, for some unknown 
reason, it
does become null. I don't know how this could happen, and I don't know how to 
protect
against it. Could this be a problem of how Tomcat loads / unloads the class?

Original comment by thomas.t...@gmail.com on 10 Nov 2008 at 5:53

GoogleCodeExporter commented 8 years ago
This should be fixed in version 1.1.104, could you try again please?

Original comment by thomas.t...@gmail.com on 30 Nov 2008 at 4:15