users@glassfish.java.net

Re: GF 3.1.1 yet another classloading issue - JEE6 EAR packaging and MANIFEST.MF

From: Andreas Loew <Andreas.Loew_at_oracle.com>
Date: Tue, 29 Nov 2011 16:22:42 +0100

Hi Bernhard,

first of all, I am assuming that you consistently made a typo: the
manifest must be named MANIFEST.MF (not .FM) in order to be read.

The error most probably is that the Class-Path entry seems to process
only zipped or "exploded" JAR files, but not directories in classical
"classes" style (i.e. the name of which does not end in .jar):

I've never seen that in practice, and section 8.2.1 on page 177 seems to
conform with my assumption:

"*Only JAR format files or directories* containing class files or
resources to be loaded directly by a standard class loader should be the
*target of a Class-Path reference*; such files *are always named with a
.jar extension*."

Do you have a particular reason why you cannot JAR up your classes to be
contained in the "classes" dir before creating the EAR?

HTH & best regards,

Andreas


Am 29.11.2011 11:13, schrieb Bernhard Thalmayr:
> Hi experts,
>
> classloading and 'portable JEE application' seems to be very
> challenging in GF 3.1.1
>
> I have a (3rd party) enterprise app with layout
>
> META-INF/application.xml
> ejb1.jar
> |_ META-INF/MANIFEST.FM <http://MANIFEST.FM> (Class-Path: lib/lib1.jar
> lib/lib2.jar classes)
>
> ejb2.jar
> |_META-INF/MANIFEST.FM <http://MANIFEST.FM> (Class-Path: lib/lib1.jar
> lib/lib3.jar classes)
>
> lib/lib1.jar
> lib/lib2.jar
> lib/lib3.jar
> classes/<package-structure>
>
> A 'NoClassDefFoundError' is raised
>
> java.lang.NoClassDefFoundError: <class-from-classes-directory>
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
> at
> com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader
> .java:756)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:186)
> at <method-of-class-from-ejb1.jar>
>
>
> As far as I interpret chapter 'EE.8' of JEE 6 specification I packaged
> the appliation correctly.
>
> Could it be that GF 3.1.1 does not honour directories mentioned in
> MANIFEST.FM <http://MANIFEST.FM> ?
>
> Section 8.2.1 states ...
>
> "The Java EE deployment tools must process all such referenced files
> and directories when processing a Java EE module."
>
> Thanks for any pointers.

-- 
Andreas Loew | Senior Java Architect
Oracle Advanced Customer Services
ORACLE Deutschland B.V. & Co. KG