I will provide a patch. Just 1 line of code is moved earlier in Database class and some minor change in Lob-related class, I tested and it works smoothly.
If you have ever heard about SymmetricDS library for synchronization of databases, they do support H2, triggers are created automatically by SymmetricDS that capture any change in table , log it in a special way and synchronize with a target database later. It's excellent framework we are using for synchronization Postgre and H2. But it uses quite a lot of CLOBs, also keeps it's configuration in CLOBs. So when triggers are initialized they try to read something from CLOB and we get the problem above. Old 1.4.181 is not affected. Vitali. On Friday, May 8, 2015 at 7:12:07 PM UTC+3, Thomas Mueller wrote: > > Hi, > > OK I see, so you are running SQL statements while initializing the > trigger. It sounds like we need to initialize the LOB storage before > creating the triggers then... Patches are welcome! > > Regards, > Thomas > > On Wednesday, May 6, 2015, Vitali <[email protected] <javascript:>> wrote: > >> >> >> Hi, Thomas. >> >> I think it's not a LOB-storage related problem. The problem as I >> specified in e-mail is that triggers during initialization are trying to >> read some CLOB data but LobStorageBackend is not yet initialized with >> a connection. Look to classes from stacktrace. It is because triggers are >> initialized earlier than LOB storage is initialized in Database class. >> >> >> >> Vitali. >> >> On Wednesday, May 6, 2015 at 9:21:48 AM UTC+3, Thomas Mueller wrote: >>> >>> Hi, >>> >>> There were some changes in this area, and an important bugfix in version >>> 1.4.187. If the LOB data was already removed before that, then I'm afraid >>> the data can not be restored easily. See also the change log for details. >>> >>> Regards, >>> Thomas >>> >>> >>> On Sunday, May 3, 2015, Vitali <[email protected]> wrote: >>> >>>> Hi. >>>> >>>> >>>> H2 containts triggers that at initialization time are trying to read >>>> from some table from LOB column. >>>> >>>> Because it occurs in org.h2.engine.Database.open(Database.java:735): >>>> >>>> org.h2.jdbc.JdbcSQLException: General error: >>>> "java.lang.NullPointerException"; SQL statement: >>>> select * from SMGIS.SYM_ON_U_FOR_TRG_TSS_HNK_FLD_CONFIG [50000-187] >>>> 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:209) >>>> at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:79) >>>> at >>>> org.jumpmind.symmetric.db.AbstractEmbeddedTrigger.getTemplates(AbstractEmbeddedTrigger.java:265) >>>> at >>>> org.jumpmind.symmetric.db.AbstractEmbeddedTrigger.init(AbstractEmbeddedTrigger.java:78) >>>> at org.jumpmind.symmetric.db.h2.H2Trigger.init(H2Trigger.java:51) >>>> at org.h2.schema.TriggerObject.load(TriggerObject.java:81) >>>> at >>>> org.h2.schema.TriggerObject.setTriggerAction(TriggerObject.java:136) >>>> at >>>> org.h2.schema.TriggerObject.setTriggerClassName(TriggerObject.java:118) >>>> at org.h2.command.ddl.CreateTrigger.update(CreateTrigger.java:115) >>>> at org.h2.engine.MetaRecord.execute(MetaRecord.java:58) >>>> at org.h2.engine.Database.open(Database.java:735) >>>> at org.h2.engine.Database.openDatabase(Database.java:266) >>>> at org.h2.engine.Database.<init>(Database.java:260) >>>> at org.h2.engine.Engine.openSession(Engine.java:60) >>>> at org.h2.engine.Engine.openSession(Engine.java:167) >>>> at org.h2.engine.Engine.createSessionAndValidate(Engine.java:145) >>>> at org.h2.engine.Engine.createSession(Engine.java:128) >>>> at org.h2.engine.Engine.createSession(Engine.java:26) >>>> at >>>> org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:347) >>>> at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:108) >>>> at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:92) >>>> at org.h2.Driver.connect(Driver.java:72) >>>> at java.sql.DriverManager.getConnection(DriverManager.java:571) >>>> at java.sql.DriverManager.getConnection(DriverManager.java:215) >>>> >>>> We get NPE as: >>>> >>>> Caused by: java.lang.NullPointerException >>>> at >>>> org.h2.store.LobStorageBackend.copyLob(LobStorageBackend.java:453) >>>> at org.h2.value.ValueLobDb.copyToResult(ValueLobDb.java:495) >>>> at org.h2.value.ValueLobDb.copyToResult(ValueLobDb.java:38) >>>> at org.h2.result.LocalResult.cloneLobs(LocalResult.java:265) >>>> at org.h2.result.LocalResult.addRow(LocalResult.java:281) >>>> at org.h2.command.dml.Select.queryFlat(Select.java:585) >>>> at org.h2.command.dml.Select.queryWithoutCache(Select.java:685) >>>> at org.h2.command.dml.Query.query(Query.java:322) >>>> at org.h2.command.dml.Query.query(Query.java:290) >>>> at org.h2.command.dml.Query.query(Query.java:36) >>>> at org.h2.command.CommandContainer.query(CommandContainer.java:90) >>>> at org.h2.command.Command.executeQuery(Command.java:197) >>>> >>>> because getLobStorage().init(); line is a bit later in >>>> Database class. >>>> >>>> >>>> Seems there was no problem in 1.4.181 that we have been using. Were >>>> there any changes in initialization logic of Database? Is loading from >>>> third-party tables in trigger a legal approach now? >>>> >>>> Vitali. >>>> >>>> -- >>>> 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 http://groups.google.com/group/h2-database. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> 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 http://groups.google.com/group/h2-database. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
