glassfish
  1. glassfish
  2. GLASSFISH-15599

AdminConsoleConfigUpgrade fails if GrizzlyConfigSchemaMigrator not run first

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1_ms07
    • Fix Version/s: 3.1_b39
    • Component/s: admin_gui
    • Labels:
      None
    • Environment:

      Earth.

      Description

      This only happens if AdminConsoleConfigUpgrade runs before GrizzlyConfigSchemaMigrator, which I haven't seen happen in the workspace or any promoted builds. But it could happen, and if it does AdminConsoleConfigUpgrade fails with:

      SEVERE: Could not upgrade security service for admin console: org.jvnet.hk2.config.TransactionFailure: Can't operate without <http-service>

      The fix for this is very simple. Here's the whole fix:

      — start —
      Index: core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminConsoleConfigUpgrade.java
      ===================================================================
      — core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminConsoleConfigUpgrade.java (revision 44566)
      +++ core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminConsoleConfigUpgrade.java (working copy)
      @@ -1,7 +1,7 @@
      /*

      • DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
        *
      • * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
        + * Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
        *
      • The contents of this file are subject to the terms of either the GNU
      • General Public License Version 2 only ("GPL") or the Common Development
        @@ -84,6 +84,11 @@
        @Inject
        Configs configs;

      + // This will force the Grizzly upgrade code to run before
      + // AdminConsoleConfigUpgrade runs.
      + @Inject(name="grizzlyconfigupgrade", optional=true)
      + ConfigurationUpgrade precondition = null;
      +
      @Override
      public void postConstruct()

      { Config config = configs.getConfigByName("server-config"); --- end --- See this email thread for more information: http://java.net/projects/glassfish/lists/dev/archive/2011-01/message/147 Note: to reproduce this, you need to make the AdminConsoleConfigUpgrade class go first. Here's one way to do it. DO NOT COMMIT THIS CODE!!! --- start --- Index: admin/config-api/src/main/java/org/glassfish/config/support/DomainXml.java =================================================================== --- admin/config-api/src/main/java/org/glassfish/config/support/DomainXml.java (revision 44566) +++ admin/config-api/src/main/java/org/glassfish/config/support/DomainXml.java (working copy) @@ -145,7 +145,21 @@ }

      protected void upgrade() {
      + /* START HACK */
      + String abc = "com.sun.enterprise.v3.admin.AdminConsoleConfigUpgrade";

      + for (Inhabitant<? extends ConfigurationUpgrade> cu : habitat.getInhabitants(ConfigurationUpgrade.class)) {
      + if (abc.equals(cu.typeName())) {
      + try

      { + cu.get(); // run the upgrade + }

      + catch (Throwable t)

      { + javax.swing.JOptionPane.showMessageDialog(null, t.getMessage()); + }

      + }
      + }
      + /* END HACK */
      +
      // run the upgrades...
      for (Inhabitant<? extends ConfigurationUpgrade> cu : habitat.getInhabitants(ConfigurationUpgrade.class)) {
      try {
      — end —

      1. fix_and_hack.diff
        2 kB
        Bobby Bissett
      2. patch0.diff
        1 kB
        Bobby Bissett
      3. patch1.diff
        0.8 kB
        Bobby Bissett
      4. patch2.diff
        3 kB
        Bobby Bissett

        Activity

        Hide
        Bobby Bissett added a comment -

        This is causing a problem in the QL tests, so am reopening the issue.

        AdminConsoleConfigUpgrade cannot run unless GrizzlyConfigSchemaMigrator runs first. In order for it to make GrizzlyConfigSchemaMigrator run first, it injects an instance of it.

        At runtime, AdminConsoleAdapter is creating an instance of AdminConsoleConfigUpgrade manually, which then tries to create an instance of GrizzlyConfigSchemaMigrator, which fails with an NPE because there is no upgrade going on. I need to figure out why AdminConsoleAdapter is doing this.

        Show
        Bobby Bissett added a comment - This is causing a problem in the QL tests, so am reopening the issue. AdminConsoleConfigUpgrade cannot run unless GrizzlyConfigSchemaMigrator runs first. In order for it to make GrizzlyConfigSchemaMigrator run first, it injects an instance of it. At runtime, AdminConsoleAdapter is creating an instance of AdminConsoleConfigUpgrade manually, which then tries to create an instance of GrizzlyConfigSchemaMigrator, which fails with an NPE because there is no upgrade going on. I need to figure out why AdminConsoleAdapter is doing this.
        Hide
        Nazrul added a comment -

        Should we exclude this issue from 3.1?

        Show
        Nazrul added a comment - Should we exclude this issue from 3.1?
        Hide
        Bobby Bissett added a comment -

        Summary:

        Upgrade modules are run by iterating over an unordered collection, so if module A needs to run before module B, it only happens by luck unless module B takes steps to force A to run first. Several modules need GrizzlyConfigSchemaMigrator to run first, and to ensure this they inject an instance of GrizzlyConfigSchemaMigrator before running. This was the fix for issue GLASSFISH-15576 for instance.

        This same fix should be made for AdminConsoleConfigUpgrade, but AdminConsoleConfigUpgrade is used during runtime by AdminConsoleAdapter, and if GrizzlyConfigSchemaMigrator is also run at this time it causes an NPE during the quicklook tests. What's annoying is that I can't reproduce the failure in any other way, and there isn't much time now to see what's going on with those tests that are otherwise fine.

        So to work around the problem, I can explicitly make GrizzlyConfigSchemaMigrator run before any other upgrade modules. Thus, it will run before AdminConsoleConfigUpgrade without any changes to AdminConsoleConfigUpgrade. This isn't an ideal solution, but we can revisit in 3.2. I think something has to be done about this, otherwise upgrades could fail randomly, or based on the user's luck.

        This patch has my change to force GrizzlyConfigSchemaMigrator to run first (getting the instance runs its postConstruct method, so getting it = running it):

        http://java.net/jira/secure/attachment/27697/patch1.diff

        It's not the ideal solution (it's a hack), but it's safer than trying to debug the whole admin console lifecycle given where we are now. If we go with this fix, I'll file a separate admin_gui issue to properly fix this in 3.2.

        Show
        Bobby Bissett added a comment - Summary: Upgrade modules are run by iterating over an unordered collection, so if module A needs to run before module B, it only happens by luck unless module B takes steps to force A to run first. Several modules need GrizzlyConfigSchemaMigrator to run first, and to ensure this they inject an instance of GrizzlyConfigSchemaMigrator before running. This was the fix for issue GLASSFISH-15576 for instance. This same fix should be made for AdminConsoleConfigUpgrade, but AdminConsoleConfigUpgrade is used during runtime by AdminConsoleAdapter, and if GrizzlyConfigSchemaMigrator is also run at this time it causes an NPE during the quicklook tests. What's annoying is that I can't reproduce the failure in any other way, and there isn't much time now to see what's going on with those tests that are otherwise fine. So to work around the problem, I can explicitly make GrizzlyConfigSchemaMigrator run before any other upgrade modules. Thus, it will run before AdminConsoleConfigUpgrade without any changes to AdminConsoleConfigUpgrade. This isn't an ideal solution, but we can revisit in 3.2. I think something has to be done about this, otherwise upgrades could fail randomly, or based on the user's luck. This patch has my change to force GrizzlyConfigSchemaMigrator to run first (getting the instance runs its postConstruct method, so getting it = running it): http://java.net/jira/secure/attachment/27697/patch1.diff It's not the ideal solution (it's a hack), but it's safer than trying to debug the whole admin console lifecycle given where we are now. If we go with this fix, I'll file a separate admin_gui issue to properly fix this in 3.2.
        Hide
        Bobby Bissett added a comment -

        This contains the proper fix as well as a check in the Grizzly code to avoid an NPE. Tested with QL and admin dev tests. Email sent to dev list about it, but the test has a manually-created config with no HttpService child object. This was causing the NPE, and I think the Grizzly code should be changed to handle that case.

        Show
        Bobby Bissett added a comment - This contains the proper fix as well as a check in the Grizzly code to avoid an NPE. Tested with QL and admin dev tests. Email sent to dev list about it, but the test has a manually-created config with no HttpService child object. This was causing the NPE, and I think the Grizzly code should be changed to handle that case.
        Hide
        Bobby Bissett added a comment -

        This is fixed in rev 44696 with the attached 'patch2' changes.

        Show
        Bobby Bissett added a comment - This is fixed in rev 44696 with the attached 'patch2' changes.

          People

          • Assignee:
            Bobby Bissett
            Reporter:
            Bobby Bissett
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: