Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-329

NullPointerException when reinstalling a component after a previous uninstall

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • incubation, 3.0-M1, 3.0-M2, 3.0.1
    • 3.0-M1
    • servicemix-core
    • None
    • win32, Sun jdk (1.4.2_09-b05)

    Description

      06/02/24 08:36:17 ERROR Failed to deploy component: TEST-BC
      java.lang.NullPointerException
      at org.apache.servicemix.jbi.util.FileUtil.buildDirectory(FileUtil.java:80)
      at org.apache.servicemix.jbi.container.EnvironmentContext.getComponentStateFile(EnvironmentContext.java:358)
      at org.apache.servicemix.jbi.framework.InstallationService.buildComponent(InstallationService.java:619)
      at org.apache.servicemix.jbi.framework.InstallationService$1.run(InstallationService.java:596)
      at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:595)
      06/02/24 08:36:17 ERROR Could not build Component: TEST-BC
      javax.jbi.management.DeploymentException: java.lang.NullPointerException
      at org.apache.servicemix.jbi.framework.InstallationService.buildComponent(InstallationService.java:632)
      at org.apache.servicemix.jbi.framework.InstallationService$1.run(InstallationService.java:596)
      at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NullPointerException
      at org.apache.servicemix.jbi.util.FileUtil.buildDirectory(FileUtil.java:80)
      at org.apache.servicemix.jbi.container.EnvironmentContext.getComponentStateFile(EnvironmentContext.java:358)
      at org.apache.servicemix.jbi.framework.InstallationService.buildComponent(InstallationService.java:619)
      ... 4 more

      1) Installed the component archive [JBIContainer.updateExternalArchive(componentArchive, true);]
      2) Uninstalled the component [InstallationService.unloadInstaller(componentName, true);]
      3) Restart the container
      4) Try to repeat 1) and it fails with the above exception.

      The problem is due to the new component version support (the code could be a liitle more readable with more meaningful method names). When a component is removed the version directory is deleted, but not the parent directory (in previous versions there was no concept of versions and thus the parent [component] directory was the one being deleted. In 3.0 the extra layer of directory has been added.

      When the component is reinstalled component root directory [in this case "TEST-BC"] already exists, but nothing else .. a condition which is not catered for in the code that generates the exception.

      Now I'm unsure where the developers are heading with the versioning support (is it really required?). Based on lack of knowledge on this part I did code a temporary fix pending someone looking at the underlying issues [e.g. should there be a state file per version, etc.]. The temporary fix is to remove the versions parent [component root] directory if it is empty [note my comment earlier about method naming .. the "root" becomes somewhat misleading with both the component and version roots. The code for this fix is shown below .. maybe you might consider putting this temporary fix in until the underlying issues are resolved?

      (Note: I have also changed the log messages to be a bit more reflective of whats going on)

      org.apache.servicemix.jbi.container.EnvironmentContext ....

      /**

      • Remove the Component root directory from the local file system
      • @param componentName
        */
        public void removeComponentRootDirectory(String componentName) {
        try {
        File file = getComponentRootDirectory(componentName);
        if (file != null) {
        if (!FileUtil.deleteFile(file)) { log.warn("Failed to remove directory structure for component [version]: " + componentName + " [" + file.getName() + ']'); }

        else {
        log.info("Removed directory structure for component [version]: " + componentName + " [" + file.getName() + ']');
        File parent = file.getParentFile();
        if (parent.list().length == 0)

        Unknown macro: { if (!FileUtil.deleteFile(parent)) { log.warn("Failed to remove root directory for component: " + componentName); } else { log.info("Removed root directory structure for component: " + componentName); } }

        }
        }
        }
        catch (IOException e)

        { log.warn("Failed to remove directory structure for component: " + componentName, e); }

        }

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            tintin David Grigglestone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: