Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.0
    • Component/s: build_system
    • Labels:
      None
    • Environment:

      Ubutu 11.04 (2.6.38-11-generic) ; Maven 3.0.3

      Description

      When trying to build GlassFish (revision 49745) with Maven 3, the build fails with the following outputs:

      ===============================================================================================================================

      • Here is the outputs from Maven:

      ===============================================================================================================================

      create-domain:
           [echo] Directory to run command from: /home/romano/workspaces/glassfish/main-scratch-mvn3_1/nucleus/distributions/atomic/target/stage/nucleus/bin
           [echo] Command to run: /home/romano/workspaces/glassfish/main-scratch-mvn3_1/nucleus/distributions/atomic/target/stage/nucleus/bin/asadmin
           [exec] Exception in thread "main" java.lang.LinkageError: injection failed on class com.sun.enterprise.admin.servermgmt.cli.CreateDomainCommand from sun.misc.Launcher$AppClassLoader@53372a1a
           [exec] 	at org.jvnet.hk2.component.InjectionManager.syncDoInject(InjectionManager.java:289)
           [exec] 	at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:105)
           [exec] 	at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:127)
           [exec] 	at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:117)
           [exec] 	at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:84)
           [exec] 	at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:141)
           [exec] 	at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:133)
           [exec] 	at org.jvnet.hk2.component.Habitat.getComponent(Habitat.java:1017)
           [exec] 	at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:182)
           [exec] 	at com.sun.enterprise.admin.cli.AsadminMain.executeCommand(AsadminMain.java:298)
           [exec] 	at com.sun.enterprise.admin.cli.AsadminMain.main(AsadminMain.java:238)
           [exec] Caused by: java.lang.NoClassDefFoundError: org/glassfish/internal/embedded/LifecycleException
           [exec] 	at java.lang.Class.getDeclaredMethods0(Native Method)
           [exec] 	at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
           [exec] 	at java.lang.Class.getDeclaredMethods(Class.java:1791)
           [exec] 	at org.jvnet.hk2.component.InjectionManager.syncDoInject(InjectionManager.java:214)
           [exec] 	... 10 more
           [exec] Caused by: java.lang.ClassNotFoundException: org.glassfish.internal.embedded.LifecycleException
           [exec] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
           [exec] 	at java.security.AccessController.doPrivileged(Native Method)
           [exec] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
           [exec] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
           [exec] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
           [exec] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
           [exec] 	... 14 more
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO] 
      [INFO] GlassFish Main Parent Project ..................... SUCCESS [32.102s]
      [..]
      [..]
      [INFO] Nucleus distributions ............................. SUCCESS [0.010s]
      [INFO] Glassfish Atomic Distribution ..................... FAILURE [0.669s]
      

      When looking at more deeply the issue, It seems that the 'asadmin create-domain' command failed over the nucleus atomic distribution...
      We can obtain the same outputs by using the following command:

      romano@frenchfish:~/workspaces/glassfish/main-scratch-mvn3_1/nucleus/distributions/atomic/target/stage/nucleus$ java -jar modules/admin-cli.jar create-domain
      Exception in thread "main" java.lang.LinkageError: injection failed on class com.sun.enterprise.admin.servermgmt.cli.CreateDomainCommand from sun.misc.Launcher$AppClassLoader@53372a1a
      	at org.jvnet.hk2.component.InjectionManager.syncDoInject(InjectionManager.java:289)
      	at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:105)
      	at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:127)
      	at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:117)
      	at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:84)
      	at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:141)
      	at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:133)
      	at org.jvnet.hk2.component.Habitat.getComponent(Habitat.java:1017)
      	at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:182)
      	at com.sun.enterprise.admin.cli.AsadminMain.executeCommand(AsadminMain.java:298)
      	at com.sun.enterprise.admin.cli.AsadminMain.main(AsadminMain.java:238)
      Caused by: java.lang.NoClassDefFoundError: org/glassfish/internal/embedded/LifecycleException
      	at java.lang.Class.getDeclaredMethods0(Native Method)
      	at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
      	at java.lang.Class.getDeclaredMethods(Class.java:1791)
      	at org.jvnet.hk2.component.InjectionManager.syncDoInject(InjectionManager.java:214)
      	... 10 more
      Caused by: java.lang.ClassNotFoundException: org.glassfish.internal.embedded.LifecycleException
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      	... 14 more
      
      1. glassfish_mvn3.diff
        5 kB
        Romain Grécourt
      2. hk2_mvn3.diff
        0.6 kB
        Romain Grécourt

        Activity

        Hide
        Romain Grécourt added a comment -

        I compared the admin-cli.jar obtained with Maven3 and Maven2, I found a difference in the MANIFEST file:

        romano@frenchfish:~/Desktop$ diff MANIFEST_MVN-2.MF MANIFEST_MVN-3.MF
        12a13,35
        > HK2-Class-Path-Id: org.glassfish.hk2.external:asm-all-repackaged:jar:1
        >  .6.18 org.glassfish.core:glassfish:jar:4.0-SNAPSHOT org.glassfish.hk2
        >  :hk2-core:jar:1.6.18 org.glassfish.hk2:class-model:jar:1.6.18 org.gla
        >  ssfish.hk2:config:jar:1.6.18 org.glassfish.hk2:auto-depends:jar:1.6.1
        >  8 org.glassfish.hk2.external:javax.inject:jar:1.6.18 org.glassfish.hk
        >  2:hk2-api:jar:1.6.18 org.glassfish.hk2:osgi-resource-locator:jar:1.0.
        >  1 org.jvnet:tiger-types:jar:1.4 org.glassfish.hk2.external:bean-valid
        >  ator:jar:1.6.18 com.googlecode.jtype:jtype:jar:0.1.0 org.glassfish:si
        >  mple-glassfish-api:jar:4.0-SNAPSHOT org.glassfish.common:common-util:
        >  jar:4.0-SNAPSHOT org.glassfish.hk2:hk2:jar:1.6.18 org.glassfish.commo
        >  n:glassfish-api:jar:4.0-SNAPSHOT org.glassfish.common:scattered-archi
        >  ve-api:jar:4.0-SNAPSHOT org.glassfish.hk2:config-types:jar:1.6.18 org
        >  .glassfish.grizzly:grizzly-framework:jar:2.1.2 org.glassfish.gmbal:gm
        >  bal-api-only:jar:3.0.0-b023 org.glassfish.external:management-api:jar
        >  :3.1.0-b001 org.glassfish.grizzly:grizzly-http-server:jar:2.1.2 org.g
        >  lassfish.grizzly:grizzly-http:jar:2.1.2 org.glassfish.grizzly:grizzly
        >  -rcm:jar:2.1.2 org.glassfish.main:j-interop-repackaged:jar:4.0-SNAPSH
        >  OT org.glassfish.admin:admin-util:jar:4.0-SNAPSHOT org.glassfish.admi
        >  n:config-api:jar:4.0-SNAPSHOT org.glassfish.grizzly:grizzly-config:ja
        >  r:2.1.2 org.glassfish.grizzly:grizzly-portunif:jar:2.1.2 org.glassfis
        >  h.hk2:osgi-adapter:jar:1.6.18 org.glassfish.common:internal-api:jar:4
        >  .0-SNAPSHOT org.glassfish.admin:launcher:jar:4.0-SNAPSHOT org.glassfi
        >  sh.core:logging:jar:4.0-SNAPSHOT
        15c38,47
        <  -l10n.jar glassfish-api.jar hk2.jar gms-adapter.jar
        ---
        >  -l10n.jar glassfish-api.jar hk2.jar gms-adapter.jar asm-all-repackage
        >  d.jar glassfish.jar hk2-core.jar class-model.jar config.jar auto-depe
        >  nds.jar javax.inject.jar hk2-api.jar osgi-resource-locator.jar tiger-
        >  types.jar bean-validator.jar jtype.jar simple-glassfish-api.jar commo
        >  n-util.jar hk2.jar glassfish-api.jar scattered-archive-api.jar config
        >  -types.jar grizzly-framework.jar gmbal-api-only.jar management-api.ja
        >  r grizzly-http-server.jar grizzly-http.jar grizzly-rcm.jar j-interop-
        >  repackaged.jar admin-util.jar config-api.jar grizzly-config.jar grizz
        >  ly-portunif.jar osgi-adapter.jar internal-api.jar launcher.jar loggin
        >  g.jar
        41c73
        < Bnd-LastModified: 1316520133280
        ---
        > Bnd-LastModified: 1316164163640
        

        We can see that the admin-cli.jar obtained when using Maven3 has no entry named HK2-Class-Path-Id in MANIFEST file.
        After some investigation and Maven debugging, I found out that the following statement from hk2-maven/src/main/java/com/sun/enterprise/module/maven/Packager.java returns a empty set.

        pom.getArtifacts()
        

        Above "pom" variable is an argument passed from the classe: hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java and is an instance of the classe: org.apache.maven.project.MavenProject. The reason of this behavior can be found in this link. Here is the most relevent quote:

        Accessing Project Dependencies
        The easiest way for a plugin to get the entire set of transitive dependencies for a project is the mojo annotation @requiresDependencyResolution. This annotation is configured with one of the values: compile, runtime or test, which denote the dependency scope a plugin is interested in. What has been proven troublesome is the subtle fact that the runtime classpath is not a superset of the compile classpath, i.e. dependencies of scope provided and system are not included in the runtime classpath.

        Now, what shall plugin authors do that need to inspect the union of the compile and runtime classpaths? So far, the answer was either to request the test classpath or to programmatically do dependency resolution with the proper scope filter. Neither of these two approaches are really attractive for one reason or the other. So we eventually added support for a new annotation value in Maven 3.0, compile+runtime, that ensures project dependencies with the scopes compile, runtime, provided and system get resolved.

        Here is the fix for this part of the issue (also available as attachment: "hk2-mvn3.diff"):

        Index: hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java
        ===================================================================
        --- hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java	(revision 2421)
        +++ hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java	(working copy)
        @@ -82,6 +82,7 @@
          * @goal package
          * @phase package
          * @requiresProject
        + * @requiresDependencyResolution
          */
         public class PackageMojo extends AbstractMojo {
             private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"};
        
        Show
        Romain Grécourt added a comment - I compared the admin-cli.jar obtained with Maven3 and Maven2, I found a difference in the MANIFEST file: romano@frenchfish:~/Desktop$ diff MANIFEST_MVN-2.MF MANIFEST_MVN-3.MF 12a13,35 > HK2-Class-Path-Id: org.glassfish.hk2.external:asm-all-repackaged:jar:1 > .6.18 org.glassfish.core:glassfish:jar:4.0-SNAPSHOT org.glassfish.hk2 > :hk2-core:jar:1.6.18 org.glassfish.hk2:class-model:jar:1.6.18 org.gla > ssfish.hk2:config:jar:1.6.18 org.glassfish.hk2:auto-depends:jar:1.6.1 > 8 org.glassfish.hk2.external:javax.inject:jar:1.6.18 org.glassfish.hk > 2:hk2-api:jar:1.6.18 org.glassfish.hk2:osgi-resource-locator:jar:1.0. > 1 org.jvnet:tiger-types:jar:1.4 org.glassfish.hk2.external:bean-valid > ator:jar:1.6.18 com.googlecode.jtype:jtype:jar:0.1.0 org.glassfish:si > mple-glassfish-api:jar:4.0-SNAPSHOT org.glassfish.common:common-util: > jar:4.0-SNAPSHOT org.glassfish.hk2:hk2:jar:1.6.18 org.glassfish.commo > n:glassfish-api:jar:4.0-SNAPSHOT org.glassfish.common:scattered-archi > ve-api:jar:4.0-SNAPSHOT org.glassfish.hk2:config-types:jar:1.6.18 org > .glassfish.grizzly:grizzly-framework:jar:2.1.2 org.glassfish.gmbal:gm > bal-api-only:jar:3.0.0-b023 org.glassfish.external:management-api:jar > :3.1.0-b001 org.glassfish.grizzly:grizzly-http-server:jar:2.1.2 org.g > lassfish.grizzly:grizzly-http:jar:2.1.2 org.glassfish.grizzly:grizzly > -rcm:jar:2.1.2 org.glassfish.main:j-interop-repackaged:jar:4.0-SNAPSH > OT org.glassfish.admin:admin-util:jar:4.0-SNAPSHOT org.glassfish.admi > n:config-api:jar:4.0-SNAPSHOT org.glassfish.grizzly:grizzly-config:ja > r:2.1.2 org.glassfish.grizzly:grizzly-portunif:jar:2.1.2 org.glassfis > h.hk2:osgi-adapter:jar:1.6.18 org.glassfish.common:internal-api:jar:4 > .0-SNAPSHOT org.glassfish.admin:launcher:jar:4.0-SNAPSHOT org.glassfi > sh.core:logging:jar:4.0-SNAPSHOT 15c38,47 < -l10n.jar glassfish-api.jar hk2.jar gms-adapter.jar --- > -l10n.jar glassfish-api.jar hk2.jar gms-adapter.jar asm-all-repackage > d.jar glassfish.jar hk2-core.jar class-model.jar config.jar auto-depe > nds.jar javax.inject.jar hk2-api.jar osgi-resource-locator.jar tiger- > types.jar bean-validator.jar jtype.jar simple-glassfish-api.jar commo > n-util.jar hk2.jar glassfish-api.jar scattered-archive-api.jar config > -types.jar grizzly-framework.jar gmbal-api-only.jar management-api.ja > r grizzly-http-server.jar grizzly-http.jar grizzly-rcm.jar j-interop- > repackaged.jar admin-util.jar config-api.jar grizzly-config.jar grizz > ly-portunif.jar osgi-adapter.jar internal-api.jar launcher.jar loggin > g.jar 41c73 < Bnd-LastModified: 1316520133280 --- > Bnd-LastModified: 1316164163640 We can see that the admin-cli.jar obtained when using Maven3 has no entry named HK2-Class-Path-Id in MANIFEST file. After some investigation and Maven debugging, I found out that the following statement from hk2-maven/src/main/java/com/sun/enterprise/module/maven/Packager.java returns a empty set. pom.getArtifacts() Above "pom" variable is an argument passed from the classe: hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java and is an instance of the classe: org.apache.maven.project.MavenProject . The reason of this behavior can be found in this link . Here is the most relevent quote: Accessing Project Dependencies The easiest way for a plugin to get the entire set of transitive dependencies for a project is the mojo annotation @requiresDependencyResolution. This annotation is configured with one of the values: compile, runtime or test, which denote the dependency scope a plugin is interested in. What has been proven troublesome is the subtle fact that the runtime classpath is not a superset of the compile classpath, i.e. dependencies of scope provided and system are not included in the runtime classpath. Now, what shall plugin authors do that need to inspect the union of the compile and runtime classpaths? So far, the answer was either to request the test classpath or to programmatically do dependency resolution with the proper scope filter. Neither of these two approaches are really attractive for one reason or the other. So we eventually added support for a new annotation value in Maven 3.0, compile+runtime, that ensures project dependencies with the scopes compile, runtime, provided and system get resolved. Here is the fix for this part of the issue (also available as attachment: "hk2-mvn3.diff"): Index: hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java =================================================================== --- hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java (revision 2421) +++ hk2-maven-plugin/src/main/java/com/sun/enterprise/module/maven/PackageMojo.java (working copy) @@ -82,6 +82,7 @@ * @goal package * @phase package * @requiresProject + * @requiresDependencyResolution */ public class PackageMojo extends AbstractMojo { private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"};
        Hide
        Romain Grécourt added a comment -

        attaching file hk2_mvn3.diff

        Show
        Romain Grécourt added a comment - attaching file hk2_mvn3.diff
        Hide
        Romain Grécourt added a comment -

        After having released a fixed version of HK2 in my local repo I've tried to continue building GlassFish (pom.xml modified accordingly) with Maven3.
        Here is the next issue faced:

        Downloading: http://maven.glassfish.org/content/groups/glassfish/org/glassfish/ejb/ejb-timer-databases/4.0-SNAPSHOT/ejb-timer-databases-4.0-SNAPSHOT.distribution-fragment
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD FAILURE
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 1:52.189s
        [INFO] Finished at: Tue Sep 20 15:24:50 CEST 2011
        [INFO] Final Memory: 12M/101M
        [INFO] ------------------------------------------------------------------------
        [ERROR] Failed to execute goal on project ejb-all: Could not resolve dependencies for project org.glassfish.ejb:ejb-all:pom:4.0-SNAPSHOT: Could not find artifact org.glassfish.ejb:ejb-timer-databases:distribution-fragment:4.0-SNAPSHOT in glassfish-repo-archive (http://maven.glassfish.org/content/groups/glassfish) -> [Help 1]
        

        It seems that when resolving the dependency of the module "ejb-timer-databases", Maven3 is searching for a file with the extension ".distribution-fragment" in the repositories. Obviously the build failed as no such artifact exists.
        According to this link it's a regression of Maven3 and the fix will be released in the next version (3.0.4). Nevertheless, according to this link there is way to bypass the problem: the 'distribution-fragment" is a special packaging introduced by the "glassfishbuild-extension" dependency, moving the dependency of the affected module into a parent pom.xml solves the issue.
        Once this bug resolved in other modules, I was able to build GlassFish with Maven3, here is a diff file available as attachment (glassfish_mvn3.diff).

        Show
        Romain Grécourt added a comment - After having released a fixed version of HK2 in my local repo I've tried to continue building GlassFish (pom.xml modified accordingly) with Maven3. Here is the next issue faced: Downloading: http://maven.glassfish.org/content/groups/glassfish/org/glassfish/ejb/ejb-timer-databases/4.0-SNAPSHOT/ejb-timer-databases-4.0-SNAPSHOT.distribution-fragment [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:52.189s [INFO] Finished at: Tue Sep 20 15:24:50 CEST 2011 [INFO] Final Memory: 12M/101M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project ejb-all: Could not resolve dependencies for project org.glassfish.ejb:ejb-all:pom:4.0-SNAPSHOT: Could not find artifact org.glassfish.ejb:ejb-timer-databases:distribution-fragment:4.0-SNAPSHOT in glassfish-repo-archive (http://maven.glassfish.org/content/groups/glassfish) -> [Help 1] It seems that when resolving the dependency of the module "ejb-timer-databases", Maven3 is searching for a file with the extension ".distribution-fragment" in the repositories. Obviously the build failed as no such artifact exists. According to this link it's a regression of Maven3 and the fix will be released in the next version (3.0.4). Nevertheless, according to this link there is way to bypass the problem: the 'distribution-fragment" is a special packaging introduced by the "glassfishbuild-extension" dependency, moving the dependency of the affected module into a parent pom.xml solves the issue. Once this bug resolved in other modules, I was able to build GlassFish with Maven3, here is a diff file available as attachment (glassfish_mvn3.diff).
        Hide
        Romain Grécourt added a comment -

        attaching "glassfish_mvn3".diff

        Show
        Romain Grécourt added a comment - attaching "glassfish_mvn3".diff
        Hide
        Romain Grécourt added a comment -

        Fix committed in HK2 (revision 2423), version 1.6.19 released.
        Fix committed in GlassFish (revision 49798).

        Show
        Romain Grécourt added a comment - Fix committed in HK2 (revision 2423), version 1.6.19 released. Fix committed in GlassFish (revision 49798).
        Hide
        Romain Grécourt added a comment -

        Marking the issue as resolved.

        Show
        Romain Grécourt added a comment - Marking the issue as resolved.
        Hide
        scatari added a comment -

        Issue doesn't apply to 3.1.2.

        Show
        scatari added a comment - Issue doesn't apply to 3.1.2.

          People

          • Assignee:
            Romain Grécourt
            Reporter:
            Romain Grécourt
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: