I would like to propose the following patch for org/h2/store/fs/ FileSystemDisk.java
in method 'openFileInputStream(String fileName)', line 372: - InputStream in = getClass().getResourceAsStream(fileName); + InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); On May 3, 8:37 pm, Xavier <[email protected]> wrote: > Nevermind my last post, using > Thread.currentThread().getContextClassLoader().getResourceAsStream() > is working and fixes my problem. > > On May 3, 8:30 pm, Xavier <[email protected]> wrote: > > > > > > > > > I tried patching FileSystemDisk to use > > Thread.currentThread().getContextClassLoader().getResourceAsStream() > > but it didn't work... I guess this classloading problem is a bit more > > complicated than expected... > > > On May 3, 5:05 pm, Xavier <[email protected]> wrote: > > > > Hi, > > > > I'm actually using H2 + Hibernate and I'm importing some data through > > > Hibernate's import.sql (which is executed after tables have been > > > created). > > > > When I have this in my import.sql: > > > > insert into files (id, name, content) values (1, 'logo.png', > > > FILE_READ('classpath:logo.png')); > > > > I get an exception like this one at deployment time: > > > > java.io.FileNotFoundException: resource /logo.png > > > at > > > org.h2.store.fs.FileSystemDisk.openFileInputStream(FileSystemDisk.java: > > > 374) > > > at org.h2.util.IOUtils.openFileInputStream(IOUtils.java:710) > > > at org.h2.expression.Function.getValueWithArgs(Function.java: > > > 1137) > > > > because H2 drivers (which live in the application server classpath) > > > can't see my application classpath (and can't find the resource > > > 'logo.png'). > > > > So would it be possible to have another parameter for FILE_READ (or > > > another procol like threadClasspath:) to instruct I want the resources > > > to be read through > > > Thread.currentThread().getContextClassLoader().getResourceAsStream() > > > instead of FileSystemDisk.class.getResourceAsStream() ? Do you think > > > it would solve my problem ? > > > > Thanks, > > > > Xavier -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
