code: public static PortletApplicationContext getRequiredPortletApplicationContext(PortletContext pc)
              throws IllegalStateException {
  
          PortletApplicationContext wac = getPortletApplicationContext(pc);
          if (wac == null) {
              throw new IllegalStateException("No PortletApplicationContext found: no PortletContextLoaderListener registered?");
          }
          return wac;
      }
docs: Find the root PortletApplicationContext for this portlet application, which is
  typically loaded via ContextLoaderFilter.
  <p>Will rethrow an exception that happened on root context startup,
  to differentiate between a failed context startup and no context at all.
  
  @param pc PortletContext to find the portlet application context for
  @return the root PortletApplicationContext for this portlet app
  @throws java.lang.IllegalStateException if the root PortletApplicationContext could not be found