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

PortalDelegateServlet doPortalInit() Not Being Invoked At Deploy-Time

    Details

      Description

      I have a Servlet WAR from a Liferay application that currently runs in Liferay 6.1.2 GA3 inside Tomcat. It uses PortalDelegateServlet to wrap all of the Servlet endpoints. I am in the process of migrating this application to Liferay 7. I am using the Liferay 7.0.1 GA2 Tomcat bundle as provided for Liferay download. The only thing I have changed is the root context so that Liferay runs under "/liferay" instead of as ROOT. I had no problems doing the initial setup of Liferay 7.0.1, and everything else out-of-the-box seems to be working fine.

      I've migrated my code base as necessary to the Liferay 7 API, so everything compiles properly. When I attempt to deploy the Servlet WAR, I see a NullPointerException in the Tomcat console output (truncated for brevity):

      14-Jun-2016 15:48:35.838 SEVERE [fileinstall-T:/liferay-ce-portal-7.0-ga2/osgi/war] org.apache.catalina.core.Application Context.log null
       java.lang.NullPointerException
              at com.liferay.portal.kernel.servlet.SecureServlet.getServletInfo(SecureServlet.java:64)
              at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletExceptionAdapter.getServletInfo(ServletExceptionAdapter.java:50)
      

      When I debug the deployment process, I see that getServletInfo() is being called on the PortalDelegateServlet object, which attempts to access the "servlet" member variable:

      SecureServlet.java
      @Override
      public String getServletInfo() {
      	return servlet.getServletInfo();
      }
      

      The "servlet" member variable is null, which causes the exception. As far as I can tell, that member variable is only initialized in the doPortalInit() method in PortalDelegateServlet, but that method is never called during deployment. I determined this by putting a breakpoint at the beginning of the method, which was never reached.

      When I debug the same deployment process in Liferay 6.1.2 with our existing functional code base, doPortalInit() IS called for every <servlet> block in my web.xml that uses PortalDelegateServlet.

      I've tried this with just one of the <servlet> blocks in my web.xml, which is fairly basic:

      <servlet>
              <servlet-name>rss-delegate-servlet</servlet-name>
              <servlet-class>com.liferay.portal.kernel.servlet.PortalDelegateServlet</servlet-class>
              <init-param>
                  <param-name>servlet-class</param-name>
                  <param-value>x.y.z.RSSServlet</param-value>
              </init-param>
              <init-param>
                  <param-name>sub-context</param-name>
                  <param-value>RSSServlet</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
          </servlet>
      

      All of my servlet classes extend HttpServlet.

      Here is the full stack trace of the exception:

      14-Jun-2016 15:48:35.838 SEVERE [fileinstall-T:/liferay-ce-portal-7.0-ga2/osgi/war] org.apache.catalina.core.Application Context.log null
       java.lang.NullPointerException
              at com.liferay.portal.kernel.servlet.SecureServlet.getServletInfo(SecureServlet.java:64)
              at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletExceptionAdapter.getServletInfo(ServletExceptionAdapter.java:50)
              at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddServletRegistration(ContextController.java:516)
              at org.eclipse.equinox.http.servlet.internal.context.ContextController.addServletRegistration(ContextController.java:449)
              at org.eclipse.equinox.http.servlet.internal.customizer.ContextServletTrackerCustomizer.addingService(ContextServletTrackerCustomizer.java:55)
              at org.eclipse.equinox.http.servlet.internal.customizer.ContextServletTrackerCustomizer.addingService(ContextServletTrackerCustomizer.java:1)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
              at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
              at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
              at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
              at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)
              at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
              at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:917)
              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.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
              at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
              at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
              at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482)
              at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1001)
              at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initServlets(WabBundleProcessor.java:624)
              at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:168)
              at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:186)
              at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:85)
              at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:162)
              at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
              at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
              at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)
              at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1)
              at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
              at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
              at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:905)
              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:165)
              at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)
              at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)
              at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)
              at org.eclipse.osgi.container.Module.publishEvent(Module.java:461)
              at org.eclipse.osgi.container.Module.start(Module.java:452)
              at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402)
              at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1252)
              at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1224)
              at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)
              at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
              at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313)
      

        Attachments

          Activity

            People

            Assignee:
            linda.sui Linda Sui
            Reporter:
            RyanTobin Ryan Tobin
            Participants of an Issue:
            Recent user:
            Csaba Turcsan
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              4 years ago

                Packages

                Version Package
                7.0.0 DXP FP8
                7.0.0 DXP SP2
                7.0.3 CE GA4
                Master