Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-98920

Non-injected bean portlet state is lost before destroy() method called

    Details

    • Type: Bug
    • Status: Verified
    • Resolution: Unresolved
    • Affects Version/s: 7.1.10.2 SP2, 7.1.3 CE GA4, 7.1.10 DXP FP12, 7.1.X, 7.2.0 GA1, 7.2.10 DXP GA1, 7.2.X, Master
    • Fix Version/s: None
    • Component/s: Core Infrastructure
    • Labels:
      None
    • Fix Priority:
      4

      Description

      Steps to reproduce:

      1. Add the following line to Liferay's portal-ext.properties file:
         module.framework.properties.osgi.console=localhost:11311
        
      2. Start Liferay.
      3. Download the attached com.mycompany.my.bean.portlet.zip project.
      4. Unzip the project:
          cd ~/Downloads && unzip com.mycompany.my.bean.portlet.zip
        
      5. Build the project:
         cd com.mycompany.my.bean.portlet && mvn clean package
        
      6. Deploy the WAR to Liferay:
         cp target/*.war $LIFERAY_HOME/deploy/.
        
      7. Confirm via the logs that the portlet was registered correctly and super.getPortletConfig() returned a non-null value in the init() method:
         17:54:59,990 DEBUG [HelloWorldPortlet:55] getPortletConfig() returned non-null value in init method
         2019-07-29 17:54:59.994 INFO  [weld-worker-2][BeanPortletExtension:429] Registered 1 bean portlets and 0 bean filters for com.mycompany.my.bean.portlet
        
      8. Connect to Liferay's Gogo shell:
         telnet localhost 11311
        
      9. Identify the portlet's id using the lb command:
         ...
         1255|Active     |   10|com.mycompany.my.bean.portlet (1.0.0)|1.0.0
        
      10. Stop the portlet bundle:
        stop 1255
        

      If the bug is fixed, the bundle will stop and the following message will appear in the logs indicating that super.getPortletConfig() returned a non-null value (which indicates that the super class state was preserved from init() to destroy()):

      17:54:59,990 DEBUG [HelloWorldPortlet:55] getPortletConfig() returned non-null value in destroy method
      

      If the bug still exists, super.getPortletConfig() will return null in the destroy() method and the following exception will appear in the logs:

      javax.portlet.PortletException: java.lang.NullPointerException
              at com.liferay.bean.portlet.cdi.extension.internal.BeanPortletInvokerPortlet._invokeBeanMethods(BeanPortletInvokerPortlet.java:393)
              at com.liferay.bean.portlet.cdi.extension.internal.BeanPortletInvokerPortlet.destroy(BeanPortletInvokerPortlet.java:97)
              at com.liferay.portlet.internal.InvokerPortletImpl.destroy(InvokerPortletImpl.java:163)
              at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.destroy(MonitoringInvokerPortlet.java:76)
              at com.liferay.portlet.internal.PortletInstanceFactoryImpl.clear(PortletInstanceFactoryImpl.java:93)
              at com.liferay.portlet.internal.PortletInstanceFactoryImpl.clear(PortletInstanceFactoryImpl.java:78)
              at com.liferay.portlet.internal.PortletInstanceFactoryImpl.destroy(PortletInstanceFactoryImpl.java:231)
              at com.liferay.portal.osgi.web.portlet.tracker.internal.PortletTracker.removedService(PortletTracker.java:225)
              at com.liferay.portal.osgi.web.portlet.tracker.internal.PortletTracker.removedService(PortletTracker.java:111)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:969)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
              at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:341)
              at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:911)
              at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:222)
              at com.liferay.bean.portlet.cdi.extension.internal.BeanPortletExtension.step6ApplicationScopedBeforeDestroyed(BeanPortletExtension.java:520)
              at sun.reflect.GeneratedMethodAccessor1087.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
              at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
              at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:129)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
              at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
              at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
              at javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:114)
              at org.jboss.weld.util.Observers.notify(Observers.java:166)
              at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
              at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
              at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
              at org.jboss.weld.bootstrap.BeanDeploymentModule.fireEvent(BeanDeploymentModule.java:93)
              at org.jboss.weld.module.web.servlet.HttpContextLifecycle.fireEventForApplicationScope(HttpContextLifecycle.java:161)
              at org.jboss.weld.module.web.servlet.HttpContextLifecycle.contextDestroyed(HttpContextLifecycle.java:153)
              at org.jboss.weld.module.web.servlet.WeldInitialListener.contextDestroyed(WeldInitialListener.java:119)
              at org.apache.aries.cdi.extension.http.HttpExtension$ListenerWrapper.contextDestroyed(HttpExtension.java:340)
              at org.eclipse.equinox.http.servlet.internal.registration.ListenerRegistration.destroy(ListenerRegistration.java:85)
              at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.removedService(ContextListenerTrackerCustomizer.java:100)
              at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.removedService(ContextListenerTrackerCustomizer.java:1)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:969)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
              at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:341)
              at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:911)
              at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:222)
              at org.apache.aries.cdi.extension.http.HttpExtension.beforeShutdown(HttpExtension.java:262)
              at sun.reflect.GeneratedMethodAccessor1086.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
              at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
              at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:129)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
              at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
              at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
              at javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:114)
              at org.jboss.weld.util.Observers.notify(Observers.java:166)
              at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
              at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
              at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
              at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
              at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
              at org.jboss.weld.bootstrap.events.BeforeShutdownImpl.fire(BeforeShutdownImpl.java:41)
              at org.jboss.weld.bootstrap.events.BeforeShutdownImpl.fire(BeforeShutdownImpl.java:32)
              at org.jboss.weld.bootstrap.WeldRuntime.shutdown(WeldRuntime.java:69)
              at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:116)
              at org.apache.aries.cdi.container.internal.container.ContainerBootstrap.close(ContainerBootstrap.java:56)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.container.Phase.submit(Phase.java:50)
              at org.apache.aries.cdi.container.internal.model.ContainerActivator.lambda$close$2(ContainerActivator.java:52)
              at java.util.Optional.map(Optional.java:215)
              at org.apache.aries.cdi.container.internal.model.ContainerActivator.close(ContainerActivator.java:50)
              at org.apache.aries.cdi.container.internal.model.ExtendedComponentInstanceDTO.lambda$null$1(ExtendedComponentInstanceDTO.java:86)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.model.ExtendedComponentInstanceDTO.lambda$close$4(ExtendedComponentInstanceDTO.java:84)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.model.ExtendedComponentInstanceDTO.close(ExtendedComponentInstanceDTO.java:73)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.container.Phase.submit(Phase.java:50)
              at org.apache.aries.cdi.container.internal.model.ContainerComponent.lambda$close$2(ContainerComponent.java:70)
              at java.util.concurrent.CopyOnWriteArrayList.removeIf(CopyOnWriteArrayList.java:907)
              at org.apache.aries.cdi.container.internal.model.ContainerComponent.close(ContainerComponent.java:66)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.container.Phase.submit(Phase.java:50)
              at org.apache.aries.cdi.container.internal.container.ConfigurationListener.lambda$close$2(ConfigurationListener.java:84)
              at java.util.Optional.map(Optional.java:215)
              at org.apache.aries.cdi.container.internal.container.ConfigurationListener.close(ConfigurationListener.java:82)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.container.Phase.submit(Phase.java:50)
              at org.apache.aries.cdi.container.internal.container.ExtensionPhase$ExtensionPhaseCustomizer.lambda$removedService$17(ExtensionPhase.java:254)
              at java.util.Optional.ifPresent(Optional.java:159)
              at org.apache.aries.cdi.container.internal.container.ExtensionPhase$ExtensionPhaseCustomizer.removedService(ExtensionPhase.java:252)
              at org.apache.aries.cdi.container.internal.container.ExtensionPhase$ExtensionPhaseCustomizer.removedService(ExtensionPhase.java:158)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:969)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
              at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:341)
              at org.osgi.util.tracker.ServiceTracker.close(ServiceTracker.java:380)
              at org.apache.aries.cdi.container.internal.container.ExtensionPhase.close(ExtensionPhase.java:56)
              at org.apache.aries.cdi.container.internal.container.ContainerState.submit(ContainerState.java:347)
              at org.apache.aries.cdi.container.internal.container.Phase.submit(Phase.java:50)
              at org.apache.aries.cdi.container.internal.container.CDIBundle.lambda$close$2(CDIBundle.java:38)
              at java.util.Optional.map(Optional.java:215)
              at org.apache.aries.cdi.container.internal.container.CDIBundle.close(CDIBundle.java:36)
              at org.apache.aries.cdi.container.internal.container.CDIBundle.destroy(CDIBundle.java:61)
              at org.apache.felix.utils.extender.AbstractExtender$2.run(AbstractExtender.java:285)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at org.apache.felix.utils.extender.AbstractExtender.destroyExtension(AbstractExtender.java:307)
              at org.apache.felix.utils.extender.AbstractExtender.bundleChanged(AbstractExtender.java:181)
              at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908)
              at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
              at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
              at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:230)
              at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:137)
              at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:129)
              at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:191)
              at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
              at org.eclipse.osgi.container.Module.doStop(Module.java:634)
              at org.eclipse.osgi.container.Module.stop(Module.java:498)
              at org.eclipse.osgi.internal.framework.EquinoxBundle.stop(EquinoxBundle.java:455)
              at org.apache.felix.gogo.command.Basic.stop(Basic.java:796)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:139)
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
              at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
              at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
              at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NullPointerException
              at com.mycompany.HelloWorldPortlet.destroy(HelloWorldPortlet.java:60)
              at com.mycompany.HelloWorldPortlet$Proxy$_$$_WeldClientProxy.destroy(Unknown Source)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.liferay.bean.portlet.cdi.extension.internal.BeanMethod.invoke(BeanMethod.java:181)
              at com.liferay.bean.portlet.cdi.extension.internal.BeanPortletInvokerPortlet._invokeBeanMethod(BeanPortletInvokerPortlet.java:341)
              at com.liferay.bean.portlet.cdi.extension.internal.BeanPortletInvokerPortlet._invokeBeanMethods(BeanPortletInvokerPortlet.java:384)
              ... 141 more
      

      Notes:

      This portlet works correctly in Apache Pluto Portal (the Portlet Specification reference implementation). The following message appears in the logs when the portlet WAR is undeployed from Pluto:

      17:54:59,990 DEBUG [HelloWorldPortlet:55] getPortletConfig() returned non-null value in destroy method
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                7 weeks, 6 days ago

                Packages

                Version Package