3 Replies Latest reply on Mar 5, 2010 2:47 PM by johnbailey

    Structure deployer cannot access manifest

    thomas.diesler

      This code used to determine whether a bundle gets deployed

       

         public boolean determineStructure(StructureContext structureContext) throws DeploymentException
         {
            VirtualFile root = structureContext.getRoot();
      
               // This file is not for me, because I'm only interested
               // in root deployments that contain a MANIFEST.MF
               Manifest manifest = VFSUtils.getManifest(root);
               if (root != structureContext.getFile() || manifest == null)
                  return false;
      
               // This file is also not for me, because I need to see Bundle-SymbolicName
               Attributes attribs = manifest.getMainAttributes();
               String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
               if (symbolicName == null)
                  return false;
      
          ....
      

       

      With deployers-2.2.0.Alpha3 (i.e. jboss-vfs-3.0.0.CR2) the manifest returned from VFSUtils is null.

       

      Is this a bug, perhaps related to the root not beeing mounted?

        • 1. Re: Structure deployer cannot access manifest
          alesj

          Is this a bug, perhaps related to the root not beeing mounted?

          Most likely -- see HERE.

           

              public static Manifest getManifest(VirtualFile archive) throws IOException {
                  if (archive == null)
                      throw new IllegalArgumentException("Null archive");
                  VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME);
                  if (manifest == null || !manifest.exists()) { // HERE -- manifest.exists() == false
                      if (log.isTraceEnabled())
                          log.trace("Can't find manifest for " + archive.getPathName());
                      return null;
                  }
                  return readManifest(manifest);
              }
          

           

          You need an explicit mount -- like explained eariler: http://community.jboss.org/message/529846#529846

           

          It will a bit tricker here, since you wanna use your VFS abstraction.

          Meaning your abstraction will have to know wheather it needs to mount or not.

          • 2. Re: Structure deployer cannot access manifest
            thomas.diesler

            I found this

             

            http://community.jboss.org/thread/148707

             

            The fix is making the DeclaredStructure extend AbstractVFSArchiveStructureDeployer to ensure the archive is mounted prior to the execution of the determineStructure method.
            • 3. Re: Structure deployer cannot access manifest
              johnbailey

              Extending AbstractVFSArchiveStructureDeployer will require you to define some kind of name matching scheme to keep it from attempting to mount files that don't make sense, like XML files.  So if you have archives, you can extends the AbstractVFSArchiveStructureDeployer and it will manage the mounting for you.  Please see the latest DeclaredStructure deployer for more details.