org.jboss.deployment.InstallerFactory.findDeployment has a bug, here are 
the symptoms:

I'm deploying 2 jars:
placement.jar  ---> is deployed first
venueplacement.jar ---> is deployed second.

placement.jar deploys successfully, but when venueplacement.jar tries to 
deploy it first undeploys placement.jar thinking that  
"venueplacement.jar" is already deployed.

Let's take a look at InstallerFactory.findDeployment:

The line with:
if (_pattern.endsWith(files[i].getName())

will sometimes resolve incorrectly, if you plug in the above example 
you'll get

if ( 
<cid:[EMAIL PROTECTED]>".../venueplacement.jar".endsWith("placement.jar"))
 
will  always be true.

THE FIX:



  public Deployment findDeployment (String _pattern)
  {
      if (_pattern == null)
          return null;

      Deployment result = null;
      String realPattern = null;
      // First try to see if _pattern is a URL.
      try
      {
          URL u = new URL(_pattern);
          String realtmp = u.getFile();
          File fp = new File(realtmp);
          realPattern = fp.getName();
      }
      catch (MalformedURLException ex)
      {
          /* Ignore, this is ok. We're dealing with an actual file path */
      }

      if (realPattern == null)
      {
          // If it's not a URL maybe it is a file path
          try
          {
          File fp = new File(_pattern);
          realPattern = fp.getName();
          }
          catch (Exception ex)
          {
          }
      }
      if (realPattern == null)
      {
          // REVISIT: Maybe we should log something here?
          return result;
      }
      File[] files =  baseDir.listFiles();
      for (int i = 0, l = files.length; i<l; ++i)
      {
          if (realPattern.equals(files[i].getName()))
          {
          try
          {
              result = loadConfig(new File (files[i], 
J2eeDeployer.CONFIG));
              break;
          }
          catch (IOException _ioe)
          {
              log.error("exception while searching deployment: 
"+_ioe.getMessage());
          }
          }
      }

      return result;
  }


Best regards,
Bill

Reply via email to