2 Replies Latest reply on Feb 18, 2010 6:18 AM by Kabir Khan

    NPE on AbstractDependencyValueMetaData.ungetValue()

    Kabir Khan Master

      Remy reported this:

       

      9:46,189 WARN  [ConfigureAction] Error unconfiguring bean
      AbstractKernelControllerContext@2fbfbe18{
      metadata=AbstractBeanMetaData@2ef49ac3{name=WarDeployer
      bean=org.jboss.web.tomcat.service.deployers.TomcatDeployer
      properties=[relativeOrder, tldJars, configFile, authenticators,
      java2ClassLoadingCompliance, domain, securityContextClassName,
      mainDeployer, policyRegistrationName, deleteWorkDirOnContextDestroy,
      securityManagementName, lenientEjbLink, defaultSecurityDomain]
      constructor=null autowireCandidate=true
      installs=[ManagedDeploymentCreator.addAttachmentType]
      uninstalls=[ManagedDeploymentCreator.removeAttachmentType]}name=WarDeployer
      target=org.jboss.web.tomcat.service.deployers.TomcatDeployer@33716286
      state=Configured
      depends=AbstractDependencyInfo@759a12cb{idependOn=[AbstractDependencyItem@4ed95bc3{name=WarDeployer
      dependsOn=ServiceBindingManager whenRequired=Configured
      dependentState=Installed resolved=false},
      AbstractDependencyItem@201787a6{name=WarDeployer
      dependsOn=MainDeployer whenRequired=Configured resolved=false},
      AbstractInstallMetaData$InstallationDependencyItem@1108565d{name=WarDeployer
      dependsOn=ManagedDeploymentCreator whenRequired=Installed
      dependentState=Installed resolved=false},
      AbstractInstallMetaData$InstallationDependencyItem@3a5dfc67{name=WarDeployer
      dependsOn=ManagedDeploymentCreator whenRequired=Installed
      dependentState=Installed resolved=false}]
      unresolved=[AbstractDependencyItem@4ed95bc3{name=WarDeployer
      dependsOn=ServiceBindingManager whenRequired=Configured
      dependentState=Installed resolved=false},
      AbstractInstallMetaData$InstallationDependencyItem@3a5dfc67{name=WarDeployer
      dependsOn=ManagedDeploymentCreator whenRequired=Installed
      dependentState=Installed resolved=false},
      AbstractInstallMetaData$InstallationDependencyItem@1108565d{name=WarDeployer
      dependsOn=ManagedDeploymentCreator whenRequired=Installed
      dependentState=Installed resolved=false},
      AbstractDependencyItem@201787a6{name=WarDeployer
      dependsOn=MainDeployer whenRequired=Configured resolved=false}]}}:
      java.lang.NullPointerException
      at org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData.ungetValue(AbstractInjectionValueMetaData.java:275)
      at org.jboss.kernel.plugins.dependency.PropertyDispatchWrapper.execute(PropertyDispatchWrapper.java:86)
      at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
      at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125)
      at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:107)
      at org.jboss.kernel.plugins.dependency.ConfigureAction.setAttributes(ConfigureAction.java:85)
      at org.jboss.kernel.plugins.dependency.ConfigureAction.uninstallActionInternal(ConfigureAction.java:58)
      at org.jboss.kernel.plugins.dependency.InstallsAwareAction.uninstallAction(InstallsAwareAction.java:175)
      at org.jboss.kernel.plugins.dependency.InstallsAwareAction.uninstallAction(InstallsAwareAction.java:42)
      at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleUninstallAction(SimpleControllerContextAction.java:79)
      at org.jboss.dependency.plugins.action.AccessControllerContextAction.uninstall(AccessControllerContextAction.java:131)
      at org.jboss.dependency.plugins.AbstractControllerContextActions.uninstall(AbstractControllerContextActions.java:58)
      at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:384)
      at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:2063)
      at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1578)
      at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1431)
      at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:735)
      at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:648)
      at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.undeploy(BeanMetaDataDeployer.java:228)
      at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.undeploy(BeanMetaDataDeployer.java:58)
      at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalUndeploy(AbstractSimpleRealDeployer.java:69)
      at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.undeploy(AbstractRealDeployer.java:117)
      at org.jboss.deployers.plugins.deployers.DeployerWrapper.undeploy(DeployerWrapper.java:204)
      at org.jboss.deployers.plugins.deployers.DeployersImpl.doUndeploy(DeployersImpl.java:1690)
      at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1597)
      at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1590)
      at org.jboss.deployers.plugins.deployers.DeployersImpl.uninstall(DeployersImpl.java:1552)
      at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:384)
      at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:2063)
      at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1578)
      at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:923)
      at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:633)
      at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:811)
      at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:654)
      at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
      at org.jboss.system.server.profileservice.repository.ProfileDeployAction.uninstall(ProfileDeployAction.java:95)
      at org.jboss.system.server.profileservice.repository.AbstractProfileAction.uninstall(AbstractProfileAction.java:70)
      at org.jboss.system.server.profileservice.repository.AbstractProfileService.uninstall(AbstractProfileService.java:417)
      at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:384)
      at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:2063)
      at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1578)
      at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:923)
      at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:633)
      at org.jboss.system.server.profileservice.repository.AbstractProfileService.deactivateProfile(AbstractProfileService.java:448)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.deactivateProfiles(ProfileServiceBootstrap.java:389)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.shutdown(ProfileServiceBootstrap.java:347)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.shutdown(ProfileServiceBootstrap.java:100)
      at org.jboss.bootstrap.impl.base.server.AbstractServer.shutdownBootstraps(AbstractServer.java:892)
      at org.jboss.bootstrap.impl.base.server.AbstractServer.shutdown(AbstractServer.java:309)
      at org.jboss.Main$ShutdownHook$1.run(Main.java:929)

      While it should be simple to change this to

        @SuppressWarnings({"deprecation"})
        public Object ungetValue(TypeInfo info, ClassLoader cl) throws Throwable
        {
           if (getUnderlyingValue() == null)
           {
              if (item != null && context != null) //Added if
              {
                 ControllerContext lookup = item.getControllerContext(context.getController()); // 275
                 if (lookup != null)
                 {
                    ungetTarget(context, lookup);
                    return null;
                 }
              }
           }
           return super.ungetValue(info, cl);
        }
      

       

      I would like to understand better how we end up in this state?

       

      context gets set in initialVisit(), and item gets set in describeVisit() and I can't see either ever being set to null on uninstall. Maybe if fromContext is used instead then context never gets set?

        • 1. Re: NPE on ungetValue()
          Kabir Khan Master

          Aha, reading the original mail helped :-)

           

          Hi,

          In AbstractWarDeployer, there is a @Inject annotation on the
          setPersistenceUnitDependencyResolver method which creates a hard
          dependency on JPA. Trying to loosen that dependency without making big
          changes, I changed it to @Inject (option=InjectOption.OPTIONAL). This
          does work to some extent (the dependency is now indeed optional), but
          it causes a NPE on shutdown.


          Any ideas ?

          Rémy

          Since it is Optional, context might not be there. I'll create a test and fix for that, and also look into what happens if we use FromContext injection.

           

          https://jira.jboss.org/jira/browse/JBKERNEL-100

          • 2. Re: NPE on ungetValue()
            Kabir Khan Master

            The problem is actually, when using contextual injection and InjectOption.OPTIONAL

            a) That AbstractInjectionValueMetaData.item is null in AIVMD.ungetValue() since it only gets set when InjectOption.STRICT is used (in describeVisit())

            b) That getUnderlyingValue() returns null in AbstractDependencyValueMetaData in its ungetValue() which also gets called

             

            I have added null checks in the ungetValue() methods.