glassfish
  1. glassfish
  2. GLASSFISH-17157

NullPointerException in BeanDeploymentArchiveImpl if CDI beans.xml is not in a WAR's WEB-INF

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.1_b12
    • Fix Version/s: 4.0
    • Component/s: cdi
    • Labels:
      None

      Description

      When someone accidently puts beans.xml into a place inside a WAR file that is not accessible to the WebappClassloader (e.g. outside of /WEB-INF), it is found in the ReadableArchive but cannot be loaded via getResource().

      java.lang.NullPointerException
      at org.glassfish.weld.BeanDeploymentArchiveImpl.handleEntry(BeanDeploymentArchiveImpl.java:504)
      at org.glassfish.weld.BeanDeploymentArchiveImpl.collectJarInfo(BeanDeploymentArchiveImpl.java:482)
      at org.glassfish.weld.BeanDeploymentArchiveImpl.populate(BeanDeploymentArchiveImpl.java:422)
      at org.glassfish.weld.BeanDeploymentArchiveImpl.<init>(BeanDeploymentArchiveImpl.java:148)
      at org.glassfish.weld.BeanDeploymentArchiveImpl.<init>(BeanDeploymentArchiveImpl.java:128)
      at org.glassfish.weld.DeploymentImpl.<init>(DeploymentImpl.java:120)
      at org.glassfish.weld.WeldDeployer.load(WeldDeployer.java:372)
      at org.glassfish.weld.WeldDeployer.load(WeldDeployer.java:99)
      at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)
      at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:257)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:360)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
      at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:145)
      at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:575)
      at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:461)
      at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:389)
      at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:380)
      at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209)
      at java.util.TimerThread.mainLoop(Timer.java:512)
      at java.util.TimerThread.run(Timer.java:462)

      The relevant code is:

      try {
          URL beansXmlUrl = Thread.currentThread().getContextClassLoader().getResource(entry);
          wUris.add(beansXmlUrl.toURI());
      } catch (URISyntaxException use) {
          logger.log(Level.WARNING, "Error handling beans.xml at " + entry, use);
      }
      

      Please add a null check and a descriptive log message...

      BTW: I am no expert, but shouldn't you use getClassLoader() here instead of Thread.currentThread().getContextClassLoader()?

        Activity

        Hide
        jjsnyder83 added a comment -

        Fixed in 3.1.2 and trunk

        Show
        jjsnyder83 added a comment - Fixed in 3.1.2 and trunk

          People

          • Assignee:
            jjsnyder83
            Reporter:
            rwruck
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: