glassfish
  1. glassfish
  2. GLASSFISH-6545

regression: NPE thrown for directory deployment

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: V3
    • Fix Version/s: 4.0_b01
    • Component/s: deployment
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      6,545
    • Status Whiteboard:
      Hide

      gfv3-prelude-excluded

      Show
      gfv3-prelude-excluded

      Description

      V3-prelude
      bld: b28a-promoted
      OS:Tested on Windows xp

      Admingui throws the following NPE while deploying directory for web application

      "An error has occurred
      Error during deployment : null : java.lang.NullPointerException"

      Server.log:
      ===========

      [#|2008-10-15T10:40:22.375-0700|WARNING|glassfish|javax.enterprise.system.core|_ThreadID=18;_ThreadName=Thread-3;|Failed
      to scan archive for annotationsnull|#]

      [#|2008-10-15T10:40:22.375-0700|SEVERE|glassfish|javax.enterprise.system.core|_ThreadID=18;_ThreadName=Thread-3;|Error
      during deployment : null
      java.lang.NullPointerException
      at
      com.sun.enterprise.deploy.shared.FileArchive.getListOfFiles(FileArchive.java:371)
      at com.sun.enterprise.deploy.shared.FileArchive.entries(FileArchive.java:170)
      at org.glassfish.persistence.jpa.JPASniffer.handles(JPASniffer.java:82)
      at com.sun.enterprise.v3.server.SnifferManager.getSniffers(SnifferManager.java:127)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:279)
      at com.sun.enterprise.v3.admin.CommandRunner$2.execute(CommandRunner.java:297)
      at com.sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:312)
      at com.sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:119)
      at com.sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:99)
      at
      org.glassfish.admingui.common.util.LocalDeploymentFacility$LocalDFCommandRunner.run(LocalDeploymentFacility.java:140)
      at
      org.glassfish.deployment.client.AbstractDeploymentFacility.deploy(AbstractDeploymentFacility.java:243)
      at
      org.glassfish.admingui.common.util.DeployUtil.invokeDeploymentFacility(DeployUtil.java:93)
      at org.glassfish.admingui.common.util.DeployUtil.deploy(DeployUtil.java:70)
      at
      org.glassfish.admingui.handlers.DeploymentHandler.deploy(DeploymentHandler.java:152)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at
      com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:422)
      at
      com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
      at
      com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
      at
      com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:132)
      at
      com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:80)
      at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
      at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
      at javax.faces.component.UICommand.broadcast(UICommand.java:372)
      at com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:160)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
      at
      com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at
      com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:80)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at
      org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:337)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:218)
      at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:370)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:250)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:218)
      at
      org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:460)
      at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
      at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
      at
      com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
      at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
      at
      com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
      at
      com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
      at
      com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
      at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
      at
      com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
      at
      com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      at
      com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
      at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
      at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)

      #]

      PS: Client and serverside deployment works fine with the same .war file

      1. SimpleHello.war
        126 kB
        sujatha_chintalapati

        Activity

        sujatha_chintalapati created issue -
        Hide
        Anissa Lam added a comment -

        I have tried this on Mac and windowXP, I cannot reproduce the problem.
        Can you zip up your directory and attach it here ?
        Can you try deploying the directory using asadmin deploy command ?

        The NPE is thrown from deployment code, transferring to deployment to take a look.

        Show
        Anissa Lam added a comment - I have tried this on Mac and windowXP, I cannot reproduce the problem. Can you zip up your directory and attach it here ? Can you try deploying the directory using asadmin deploy command ? The NPE is thrown from deployment code, transferring to deployment to take a look.
        Hide
        Tim Quinn added a comment -

        Here it the source code of FileArchive:

        368 if(directory == null || !directory.isDirectory())
        369 return;
        370
        371 for (File aList : directory.listFiles()) {

        The only way this line can trigger a NPE at 371 is if directory (which cannot
        itself be null by this time) returns null from its listFiles method. And
        according to the JavaDoc for File.listFiles() this happens only if 'directory'
        is not a directory (which should be impossible due to the earlier check) or if
        there is an I/O error in trying to list the files.

        Certainly we can improve the logic to check for this case rather than blindly
        assuming that listFiles returns a non-null value, but does this give you any
        hints as to what might be happening in your environment?

        As Anissa said, a sample directory zipped up and attached to this issue would e
        of help.

        Show
        Tim Quinn added a comment - Here it the source code of FileArchive: 368 if(directory == null || !directory.isDirectory()) 369 return; 370 371 for (File aList : directory.listFiles()) { The only way this line can trigger a NPE at 371 is if directory (which cannot itself be null by this time) returns null from its listFiles method. And according to the JavaDoc for File.listFiles() this happens only if 'directory' is not a directory (which should be impossible due to the earlier check) or if there is an I/O error in trying to list the files. Certainly we can improve the logic to check for this case rather than blindly assuming that listFiles returns a non-null value, but does this give you any hints as to what might be happening in your environment? As Anissa said, a sample directory zipped up and attached to this issue would e of help.
        Hide
        sujatha_chintalapati added a comment -

        Created an attachment (id=1984)
        attachinf file

        Show
        sujatha_chintalapati added a comment - Created an attachment (id=1984) attachinf file
        Hide
        sujatha_chintalapati added a comment -

        It looks like it is a permission problem.After giving permission to directory
        and files, it works fine. But the error message should not be "NullPointer
        Exception", it needs to be corrected. I can not even zip the directory because
        of this issue, it says access denied. I am attaching the SimpleHello.war file
        and reproduce vsteps.

        To reproduce problem:
        =====================

        1. Deploy attached .war module
        2. Go to "c:\install\domains\domain1\applications", verify the permissions for
        the directory "SimpeHello". It looks all the permissions are missing.

        3.c:\insatll\domains\domain1\applications> ls -l SimpleHello.
        d---------+ 2 mkpasswd 0 Oct 15 13:59 SimpleHello

        C:\install\domains\domain1\applications>ls -l SimpleHello

        total 1
        d---------+ 2 mkpasswd 0 Oct 15 13:59 META-INF
        d---------+ 4 mkpasswd 0 Oct 15 13:59 WEB-INF
        ---------- 1 mkpasswd 336 Oct 15 13:59 greeting.html

        4. When copy this "SimpleHello" to different directory (c:\samples\SimmpleHello)
        and later use it for directory deployment, I am getting reported NPE.

        cp -r SimpleHello c:\samples\

        5. When giving permissions to the directory and its files, directory deployment
        works fine.

        Note: I never seen this problem with 9.1 and 9.1.1 even on windows.
        Fallowing same above steps 1-5, I didn't see this problem for 9.1.1 latest
        b55-promoted build on AIx machine.

        /export/../9.1.1/b55-promoted/domains/domain1/applications/j2ee-modules> ls -l
        drwxr-xr-x 2 root system 512 Oct 15 13:13 SimpleHello/

        /export/../9.1.1/b55-promoted/domains/domain1/applications/j2ee-modules> ls -l
        SimpleHello/
        total 24
        drwxr-xr-x 2 root system 512 Oct 15 13:13 META-INF/
        drwxr-xr-x 4 root system 512 Oct 15 13:13 WEB-INF/
        rw-rr- 1 root system 336 Oct 15 13:13 greeting.html

        Show
        sujatha_chintalapati added a comment - It looks like it is a permission problem.After giving permission to directory and files, it works fine. But the error message should not be "NullPointer Exception", it needs to be corrected. I can not even zip the directory because of this issue, it says access denied. I am attaching the SimpleHello.war file and reproduce vsteps. To reproduce problem: ===================== 1. Deploy attached .war module 2. Go to "c:\install\domains\domain1\applications", verify the permissions for the directory "SimpeHello". It looks all the permissions are missing. 3.c:\insatll\domains\domain1\applications> ls -l SimpleHello. d---------+ 2 mkpasswd 0 Oct 15 13:59 SimpleHello C:\install\domains\domain1\applications>ls -l SimpleHello total 1 d---------+ 2 mkpasswd 0 Oct 15 13:59 META-INF d---------+ 4 mkpasswd 0 Oct 15 13:59 WEB-INF ---------- 1 mkpasswd 336 Oct 15 13:59 greeting.html 4. When copy this "SimpleHello" to different directory (c:\samples\SimmpleHello) and later use it for directory deployment, I am getting reported NPE. cp -r SimpleHello c:\samples\ 5. When giving permissions to the directory and its files, directory deployment works fine. Note: I never seen this problem with 9.1 and 9.1.1 even on windows. Fallowing same above steps 1-5, I didn't see this problem for 9.1.1 latest b55-promoted build on AIx machine. /export/../9.1.1/b55-promoted/domains/domain1/applications/j2ee-modules> ls -l drwxr-xr-x 2 root system 512 Oct 15 13:13 SimpleHello/ /export/../9.1.1/b55-promoted/domains/domain1/applications/j2ee-modules> ls -l SimpleHello/ total 24 drwxr-xr-x 2 root system 512 Oct 15 13:13 META-INF/ drwxr-xr-x 4 root system 512 Oct 15 13:13 WEB-INF/ rw-r r - 1 root system 336 Oct 15 13:13 greeting.html
        Hide
        sujatha_chintalapati added a comment -

        I have used glassfish-v3-prelude-b28-windows.exe for installation. It looks
        like the problem is only with windows. Downgrading bug to p3.

        Show
        sujatha_chintalapati added a comment - I have used glassfish-v3-prelude-b28-windows.exe for installation. It looks like the problem is only with windows. Downgrading bug to p3.
        Hide
        Tim Quinn added a comment -

        Sujatha,

        Can you please post your ls -l output for c:\ (I only need the line for the
        "install" directory), c:\install, ... down to c:\install\domains\domain1 (so I
        see the line for applications)?

        It will be useful to know what the permissions are for these directories on your
        system.

        As we both mentioned, a NPE is not the right error to report when this problem
        occurs. We will fix that, perhaps for prelude but certainly for the next v3
        release.

        Show
        Tim Quinn added a comment - Sujatha, Can you please post your ls -l output for c:\ (I only need the line for the "install" directory), c:\install, ... down to c:\install\domains\domain1 (so I see the line for applications)? It will be useful to know what the permissions are for these directories on your system. As we both mentioned, a NPE is not the right error to report when this problem occurs. We will fix that, perhaps for prelude but certainly for the next v3 release.
        Hide
        kumara added a comment -

        This is a very limited usage scenario and we do not expect majority of users to
        run into this issue.

        Show
        kumara added a comment - This is a very limited usage scenario and we do not expect majority of users to run into this issue.
        Hide
        sueann added a comment -

        Will add to Issues section in Release Notes.

        Show
        sueann added a comment - Will add to Issues section in Release Notes.
        Hide
        sueann added a comment -

        Listed in Release Notes Issues section, page 15.

        Show
        sueann added a comment - Listed in Release Notes Issues section, page 15.
        Hide
        kumara added a comment -

        Reclassifying as P4 because these issues are not must fix for prelude release.
        This issue will be scrubbed after prelude release and will be given the right
        priority for v3 final release.

        Show
        kumara added a comment - Reclassifying as P4 because these issues are not must fix for prelude release. This issue will be scrubbed after prelude release and will be given the right priority for v3 final release.
        Hide
        sujatha_chintalapati added a comment -

        I have verified the problem with V3Build:47d on windows.Didn't reproduce
        reported NPE anf directory permissions problems with
        attached "SimpleHello.war" .Directory deployment also works fine.
        drwxrwxrwx 1 Administrator None 0 May 26 15:09 META-INF
        drwxrwxrwx 1 Administrator None 0 May 26 15:09 WEB-INF
        -rwxrwxrwa 1 Administrator None 336 May 26 15:09
        greeting.html

        Note: But I can not "Launch" the deployed application "SimpleHello" and
        getting "404" status. Same application works fine with Glassfish2.1 Sailfin b15-
        promoted build.

        Show
        sujatha_chintalapati added a comment - I have verified the problem with V3Build:47d on windows.Didn't reproduce reported NPE anf directory permissions problems with attached "SimpleHello.war" .Directory deployment also works fine. drwxrwxrwx 1 Administrator None 0 May 26 15:09 META-INF drwxrwxrwx 1 Administrator None 0 May 26 15:09 WEB-INF -rwxrwxrwa 1 Administrator None 336 May 26 15:09 greeting.html Note: But I can not "Launch" the deployed application "SimpleHello" and getting "404" status. Same application works fine with Glassfish2.1 Sailfin b15- promoted build.
        Hide
        Anissa Lam added a comment -

        I saw this in the v3 release note and yes, this is still reproducible in 74b.
        Sounds like this was overlooked by the deployment team because this is a P4.
        You may want to move this back to P3 after v3.

        Show
        Anissa Lam added a comment - I saw this in the v3 release note and yes, this is still reproducible in 74b. Sounds like this was overlooked by the deployment team because this is a P4. You may want to move this back to P3 after v3.
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 6545 38149
        Hide
        Tim Quinn added a comment -

        Fix checked in.

        Project: glassfish
        Repository: svn
        Revision: 45276
        Author: tjquinn
        Date: 2011-02-25 20:59:01 UTC
        Link:

        Log Message:
        ------------
        Fix for 6545

        The FileArchive class implements the Archive interface for a directory tree (as opposed to a JAR for example). The method which finds all files within a directory could fail with an NPE because file.listFiles can return null (if the file is not a directory or, in this case, if file permissions prevented GlassFish from getting the list of files).

        These changes detect a null return from file.listFiles and logs a WARNING-level message before returning, thus avoiding the NPE.

        Tests: new unit test for inability to access directory; deployment devtests

        Revisions:
        ----------
        45276

        Modified Paths:
        ---------------
        trunk/v3/deployment/common/src/main/java/com/sun/enterprise/deploy/shared/FileArchive.java
        trunk/v3/deployment/common/src/main/resources/com/sun/logging/enterprise/system/tools/deployment/LogStrings.properties
        trunk/v3/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java

        Show
        Tim Quinn added a comment - Fix checked in. Project: glassfish Repository: svn Revision: 45276 Author: tjquinn Date: 2011-02-25 20:59:01 UTC Link: Log Message: ------------ Fix for 6545 The FileArchive class implements the Archive interface for a directory tree (as opposed to a JAR for example). The method which finds all files within a directory could fail with an NPE because file.listFiles can return null (if the file is not a directory or, in this case, if file permissions prevented GlassFish from getting the list of files). These changes detect a null return from file.listFiles and logs a WARNING-level message before returning, thus avoiding the NPE. Tests: new unit test for inability to access directory; deployment devtests Revisions: ---------- 45276 Modified Paths: --------------- trunk/v3/deployment/common/src/main/java/com/sun/enterprise/deploy/shared/FileArchive.java trunk/v3/deployment/common/src/main/resources/com/sun/logging/enterprise/system/tools/deployment/LogStrings.properties trunk/v3/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
        Tim Quinn made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.2_b01 [ 14675 ]
        Fix Version/s V3 [ 10981 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Tim Quinn
            Reporter:
            sujatha_chintalapati
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: