On Mon, May 18, 2009 at 3:03 PM, Jan Luehe <Jan.Luehe_at_sun.com> wrote:
> On 05/16/09 09:44 AM, Nicolás Lichtmaier wrote:
>
>> I'm trying to use ehcache as a cache provider in Hibernate. Ehcache loads
>> its configuration from an xml included in its jar, but I'm getting this
>> exception on application deployment:
>>
>> INFO: building session factory
>> GRAVE: Exception while invoking class
>> org.glassfish.persistence.jpa.JPADeployer prepare method
>> java.lang.NullPointerException
>>
>
> Can you try with a more recent GlassFish v3 build and see if you can
> reproduce the NPE?
>
> Line 2230 of WebappClassLoader.java currently reads like this:
>
> ResourceEntry entry = null;
>
> which will never cause any NPE.
I've tried now enabling Hibernate's 2nd level cache again, this time with
Glassfish v3 preview. I'm getting the same exception (with different line
numbers):
java.lang.NullPointerException
at
org.glassfish.web.loader.WebappClassLoader.findResourceInternalFromJars(WebappClassLoader.java:2278)
at
org.glassfish.web.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:2116)
at
org.glassfish.web.loader.WebappClassLoader.findResource(WebappClassLoader.java:1047)
at
org.glassfish.web.loader.WebappClassLoader.getResource(WebappClassLoader.java:1191)
at java.lang.Class.getResource(Class.java:2074)
[...]
I've tracked it down to this (assuming I've found the right svn tag
correctly):
resourceFile = new File
(loaderDir, jarEntry2.getName());
resourceFile.getParentFile().mkdirs();
What if the file is at the top level (as is the file in ehcache)?
getParentFile() will return null! In this case, there's no need to create
any directory, as the file should just be at the root. So this needs just an
"if"... am I right?
Thanks!