dev@glassfish.java.net

NPE from DefaultModuleDefinition

From: Martin Grebac <Martin.Grebac_at_Sun.COM>
Date: Mon, 31 Mar 2008 19:05:14 +0200

Hi,
 I'm getting the NPE below from hk2 trying to make my groovy sniffer
work with v3:

[#|2008-03-31T10:26:42.684+0200|SEVERE|GlassFish10.0|javax.enterprise.system.tools.deployment|_ThreadID=11;_ThreadName=Thread-4;|Exception
while deploying the app
java.lang.NullPointerException
   at
com.sun.enterprise.module.common_impl.DefaultModuleDefinition.parseClassPath(DefaultModuleDefinition.java:153)

   at
com.sun.enterprise.module.common_impl.DefaultModuleDefinition.<init>(DefaultModuleDefinition.java:101)

   at
com.sun.enterprise.module.impl.CookedModuleDefinition.<init>(CookedModuleDefinition.java:50)

   at com.sun.enterprise.groovy.GroovySniffer.setup(GroovySniffer.java:81)
   at
com.sun.enterprise.v3.server.ContainerStarter.startContainer(ContainerStarter.java:103)

   at
com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainer(ApplicationLifecycle.java:742)

   at
com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:411)

   at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:275)


the issue is that some of the jars from grails don't include metadata
element. May I fix it (see attached patch) or is there anything wrong
with what I do?

Thanks,
  MartinG

-- 
Martin Grebac
Web Technologies & Standards
Sun Microsystems Czech
ICQ: 93478885


# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /Users/snajper/work/sources/glassfish/hk2/hk2/core/src/java/com/sun/enterprise/module/common_impl
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: DefaultModuleDefinition.java
--- DefaultModuleDefinition.java Base (BASE)
+++ DefaultModuleDefinition.java Locally Modified (Based On LOCAL)
@@ -150,12 +150,14 @@
             File file = new File(result);
             if (file.exists()) {
                 Jar jar = Jar.create(file);
- if(jar.getManifest().getMainAttributes().getValue("HK2-Bundle-Name")==null)
+ Manifest m = jar.getManifest();
+ if ((m != null) && (m.getMainAttributes().getValue("HK2-Bundle-Name")==null)) {
                     // if Class-Path refers to other HK2 modules, ignore loading metadata
                     // When someone makes HK2 module bootable from Java (that is, to have the main method),
                     // it often needs to refer to other jars. The parent-first classloader delegation
                     // helps us avoid loading dupliates, but metadata needs to be ignored here.
                     jar.loadMetadata(metadata);
+ }
                 classPath.add(result);
             } else {
                 // even if the pointed resource doesn't exist, don't complain by default,