glassfish
  1. glassfish
  2. GLASSFISH-19699

ClassNotFoundException for JdbcResourceInjector when install-node is run

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0_b76_EE7MS5
    • Fix Version/s: 4.0_b81
    • Component/s: distributed management
    • Labels:
      None

      Description

      When the install-node command is run, the following exception is printed:

      $ asadmin install-node x
      MultiException stack 1 of 1
      java.lang.ClassNotFoundException: org.glassfish.jdbc.config.JdbcResourceInjector
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at org.jvnet.hk2.internal.Utilities.loadClass(Utilities.java:464)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.loadClass(ServiceLocatorImpl.java:1618)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:360)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:1678)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetDescriptor(ServiceLocatorImpl.java:895)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:1141)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:1130)
      at org.jvnet.hk2.config.DomDocument.getModelByElementName(DomDocument.java:156)
      at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:164)
      at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:231)
      at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:238)
      at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:190)
      at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:100)
      at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:130)
      at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:116)
      at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:112)
      at com.sun.enterprise.admin.cli.cluster.NativeRemoteCommandsBase.checkIfNodeExistsForHost(NativeRemoteCommandsBase.java:340)
      at com.sun.enterprise.admin.cli.cluster.InstallNodeBaseCommand.validate(InstallNodeBaseCommand.java:100)
      at com.sun.enterprise.admin.cli.cluster.InstallNodeSshCommand.validate(InstallNodeSshCommand.java:95)
      at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:296)
      at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:352)
      at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:289)
      at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:54)

      It doesn't matter what hostname is passed to the command (I used "x" in this case). If you pass in more arguments, you get even more exceptions. This doesn't seem to effect the operation of the command.

        Activity

        Hide
        Tom Mueller added a comment -

        This output appears to be coming from line 359 of NativeRemoteCommandsBase.java where it catches an exception while parsing the domain.xml. It seems odd that this class is parsing all of the domain.xml files from all of the domains in the default domains directory. If multiple domains are going to be checked, why check those in the default domains directory. What if there are other domains in other directories that are unknown to this command. It seems that this check is a halfhearted attempt to make sure that this node isn't already installed in some other domain. Since it doesn't check all domains, it doesn't seem worth doing.

        I suspect that the reason for the exception is that the entire modules directory is not in the classpath for the local command, so it isn't able to access all classes that are needed to be able to parse a domain.xml file. The command would need to create a class loader based on the entire modules directory in order to parse the domain.xml file.

        Show
        Tom Mueller added a comment - This output appears to be coming from line 359 of NativeRemoteCommandsBase.java where it catches an exception while parsing the domain.xml. It seems odd that this class is parsing all of the domain.xml files from all of the domains in the default domains directory. If multiple domains are going to be checked, why check those in the default domains directory. What if there are other domains in other directories that are unknown to this command. It seems that this check is a halfhearted attempt to make sure that this node isn't already installed in some other domain. Since it doesn't check all domains, it doesn't seem worth doing. I suspect that the reason for the exception is that the entire modules directory is not in the classpath for the local command, so it isn't able to access all classes that are needed to be able to parse a domain.xml file. The command would need to create a class loader based on the entire modules directory in order to parse the domain.xml file.
        Hide
        Byron Nevins added a comment -

        Revision 43131 -

        The problem is in InstallNodeBaseCommand.java
        method == validate()

        What it does

        A check of the domains that just happen to be in the default domains dir is performed.

        Line 340 -->
        DomDocument doc = parser.parse(domainURL);

        That line throws an Exception. A stacktrace is dumped (To scare the user?), the Exception is swallowed and totally ignored. It returns false, which then has no further effect.

        Show
        Byron Nevins added a comment - Revision 43131 - The problem is in InstallNodeBaseCommand.java method == validate() What it does A check of the domains that just happen to be in the default domains dir is performed. Line 340 --> DomDocument doc = parser.parse(domainURL); That line throws an Exception. A stacktrace is dumped (To scare the user?), the Exception is swallowed and totally ignored. It returns false, which then has no further effect.
        Hide
        Yamini K B added a comment -

        There are 2 issues here:
        1. Looking through the history of NativeRemoteCommandBase, there has been some changes related to HK2 which is causing the exception. The following change fixes that:

        Index: src/main/java/com/sun/enterprise/admin/cli/cluster/NativeRemoteCommandsBase.java
        ===================================================================
        — src/main/java/com/sun/enterprise/admin/cli/cluster/NativeRemoteCommandsBase.java (revision 59713)
        +++ src/main/java/com/sun/enterprise/admin/cli/cluster/NativeRemoteCommandsBase.java (working copy)
        @@ -65,6 +65,8 @@
        import com.sun.enterprise.config.serverbeans.Domain;
        import com.sun.enterprise.config.serverbeans.Nodes;
        import com.sun.enterprise.config.serverbeans.Node;
        +import com.sun.enterprise.module.ModulesRegistry;
        +import com.sun.enterprise.module.single.StaticModulesRegistry;

        import com.sun.enterprise.universal.glassfish.TokenResolver;
        import com.sun.enterprise.util.io.DomainDirs;
        @@ -327,14 +329,9 @@
        }
        );

        • ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create("default");
        • try { - HK2Populator.populate(serviceLocator, new ClasspathDescriptorFileFinder(cl), null); - }

          catch (IOException e)

          { - logger.log(Level.SEVERE, "Error initializing HK2", e); - }
        • + ModulesRegistry registry = new StaticModulesRegistry(cl);
          + ServiceLocator serviceLocator = registry.createServiceLocator("default");
          +
          ConfigParser parser = new ConfigParser(serviceLocator);
          URL domainURL = domainXMLFile.toURI().toURL();
          DomDocument doc = parser.parse(domainURL);

        2. The command should scan domains in user configured domains dir as well.

        Show
        Yamini K B added a comment - There are 2 issues here: 1. Looking through the history of NativeRemoteCommandBase, there has been some changes related to HK2 which is causing the exception. The following change fixes that: Index: src/main/java/com/sun/enterprise/admin/cli/cluster/NativeRemoteCommandsBase.java =================================================================== — src/main/java/com/sun/enterprise/admin/cli/cluster/NativeRemoteCommandsBase.java (revision 59713) +++ src/main/java/com/sun/enterprise/admin/cli/cluster/NativeRemoteCommandsBase.java (working copy) @@ -65,6 +65,8 @@ import com.sun.enterprise.config.serverbeans.Domain; import com.sun.enterprise.config.serverbeans.Nodes; import com.sun.enterprise.config.serverbeans.Node; +import com.sun.enterprise.module.ModulesRegistry; +import com.sun.enterprise.module.single.StaticModulesRegistry; import com.sun.enterprise.universal.glassfish.TokenResolver; import com.sun.enterprise.util.io.DomainDirs; @@ -327,14 +329,9 @@ } ); ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create("default"); try { - HK2Populator.populate(serviceLocator, new ClasspathDescriptorFileFinder(cl), null); - } catch (IOException e) { - logger.log(Level.SEVERE, "Error initializing HK2", e); - } + ModulesRegistry registry = new StaticModulesRegistry(cl); + ServiceLocator serviceLocator = registry.createServiceLocator("default"); + ConfigParser parser = new ConfigParser(serviceLocator); URL domainURL = domainXMLFile.toURI().toURL(); DomDocument doc = parser.parse(domainURL); 2. The command should scan domains in user configured domains dir as well.
        Hide
        Tom Mueller added a comment -

        WRT #2 in the previous comment, there is no way of knowing where the "user configured domains dirs" might be. They are not configured. Domains directories are only ever specified using a --domaindir option.

        Other than list-domains, we don't have any command that looks at or does anything to more than one domain. And with list-domains, it only looks at the domains in the directory passed via the --domaindir option (or the default).

        I strongly recommend that this "feature" of looking at multiple domains be removed from the install-node command.

        Show
        Tom Mueller added a comment - WRT #2 in the previous comment, there is no way of knowing where the "user configured domains dirs" might be. They are not configured. Domains directories are only ever specified using a --domaindir option. Other than list-domains, we don't have any command that looks at or does anything to more than one domain. And with list-domains, it only looks at the domains in the directory passed via the --domaindir option (or the default). I strongly recommend that this "feature" of looking at multiple domains be removed from the install-node command.
        Hide
        Yamini K B added a comment -

        Fix checked in r60828

        Show
        Yamini K B added a comment - Fix checked in r60828

          People

          • Assignee:
            Yamini K B
            Reporter:
            Tom Mueller
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: