1 Reply Latest reply on Sep 8, 2008 8:39 AM by alesj

    Misleading error message: Error determining structure: my.ea

    jaysperk

      My ear file had a jar file in it that could not be read (not sure why that was - I ended up getting a later version that worked) but instead of getting a nice error telling me which jar file was bad, I got the following stacktrace:

      12:41:36,926 ERROR [ProfileServiceBootstrap] Failed to load profile:
      org.jboss.deployers.spi.DeploymentException: Error determining structure: StepUnitTests.ear
      at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
      at org.jboss.deployers.vfs.plugins.structure.jar.JARStructure.determineStructure(JARStructure.java:152)
      at org.jboss.deployers.vfs.plugins.structure.StructureDeployerWrapper.determineStructure(StructureDeployerWrapper.java:65)
      at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.doDetermineStructure(VFSStructuralDeployersImpl.java:194)
      at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.determineStructure(VFSStructuralDeployersImpl.java:218)
      at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:77)
      at org.jboss.deployers.plugins.main.MainDeployerImpl.determineStructure(MainDeployerImpl.java:743)
      at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:280)
      at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:237)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:245)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:131)
      at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:408)
      at org.jboss.Main.boot(Main.java:208)
      at org.jboss.Main$1.run(Main.java:534)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.IllegalStateException: File cannot contain children: FileHandler@8436083[path=StepUnitTests.ear context=file:/C:/software/jboss-5.0.0.Beta4/server/default/deploy/ real=file:/C:/software/jboss-5.0.0.Beta4/server/default/deploy/StepUnitTests.ear]
      at org.jboss.virtual.VirtualFile.visit(VirtualFile.java:361)
      at org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer.addChildren(AbstractStructureDeployer.java:217)
      at org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer.addAllChildren(AbstractStructureDeployer.java:198)
      at org.jboss.deployers.vfs.plugins.structure.jar.JARStructure.determineStructure(JARStructure.java:143)
      ... 13 more

      The culprit appears to be in the FileSystemContext.class in the createVirtualFileHandler() method - as you can see, when an IOException occurs while instantiating the JarHandler, it is caught, logged and then the code proceeds to create just a regular file handler for your ear instead of a jar handler. This is the reason the structure cannot be determined, because the EARStructure class doesn't recognize an EAR that is a regular file handler (because it reports that it is a leaf where as a JarHandler wouldn't report itself as a leaf).

      I am posting it here in case someone else runs into this problem, but it would be nice if a meaningful exception could be thrown at the time the problem occurs. Or at least log the stack trace when the error occurs. I turned on logging while investigating this issue, but I missed the debug message. Finding the debug message would be like finding a needle in a haystack with all the other logging going on.

      Here is a snipped of the code I am referring to:
      public VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent, File file) throws IOException
       {
       if (file == null)
       throw new IllegalArgumentException("Null file");
      
       URI fileURL = getFileURI(file);
       if (file.isFile() && JarUtils.isArchive(file.getName()))
       {
       String name = file.getName();
       try
       {
       return new JarHandler(this, parent, file, file.toURL(), name);
       }
       catch (IOException e)
       {
       log.debug(e.getMessage());
       }
       }
       return createVirtualFileHandler(parent, file, fileURL);
       }