5 Replies Latest reply: May 28, 2012 4:49 AM by Minh Hoang TO RSS

PortletInitializationException thrown for not implementing javax.portlet.filter.PortletFilter

Thomas Kerle Newbie

Hi all,

 

I have the following problem since I updated my web-application to the newest version of Tomcat 7.27. I get the following exception when I start up Tomcat from Eclipse (Helios):

 

ERROR LifeCycle - Cannot start object org.gatein.pc.portlet.container.PortletInitializationException: Cannot create filter with class com.qnamic.railopt.web.security.portlet.PortletSecurityFilter because it does not implement the expected interface javax.portlet.filter.PortletFilter at org.gatein.pc.portlet.impl.jsr168.ClassInstanceLifeCycle.create(ClassInstanceLifeCycle.java:85)  at org.gatein.pc.portlet.impl.jsr168.PortletFilterImpl.start(PortletFilterImpl.java:144)  at org.gatein.pc.portlet.impl.container.PortletFilterLifeCycle.invokeStart(PortletFilterLifeCycle.java:66)  at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:93)  at org.gatein.pc.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:339)  at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:129)  at org.gatein.pc.mc.PortletApplicationDeployment.install(PortletApplicationDeployment.java:153)  at org.gatein.pc.mc.PortletApplicationDeployer.add(PortletApplicationDeployer.java:216)  at org.gatein.pc.mc.PortletApplicationDeployer.onEvent(PortletApplicationDeployer.java:185)  at org.gatein.wci.impl.DefaultServletContainer.safeFireEvent(DefaultServletContainer.java:200)  at org.gatein.wci.impl.DefaultServletContainer.fireEvent(DefaultServletContainer.java:219)  at org.gatein.wci.impl.DefaultServletContainer.access$400(DefaultServletContainer.java:60)  at org.gatein.wci.impl.DefaultServletContainer$RegistrationImpl.registerWebApp(DefaultServletContainer.java:338)  at org.gatein.wci.tomcat.TC7ServletContainerContext.start(TC7ServletContainerContext.java:380)  at org.gatein.wci.tomcat.TC7ServletContainerContext.lifecycleEvent(TC7ServletContainerContext.java:234)  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)  at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)  at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  at java.lang.Thread.run(Thread.java:619) A: S: R: U: ERROR LifeCycle - Cannot start object org.gatein.pc.portlet.container.PortletInitializationException: Cannot create filter with class com.qnamic.railopt.web.core.portal.ContextFilter because it does not implement the expected interface javax.portlet.filter.PortletFilter at org.gatein.pc.portlet.impl.jsr168.ClassInstanceLifeCycle.create(ClassInstanceLifeCycle.java:85)  at org.gatein.pc.portlet.impl.jsr168.PortletFilterImpl.start(PortletFilterImpl.java:144)  at org.gatein.pc.portlet.impl.container.PortletFilterLifeCycle.invokeStart(PortletFilterLifeCycle.java:66)  at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:93)  at org.gatein.pc.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:339)  at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:129)  at org.gatein.pc.mc.PortletApplicationDeployment.install(PortletApplicationDeployment.java:153)  at org.gatein.pc.mc.PortletApplicationDeployer.add(PortletApplicationDeployer.java:216)  at org.gatein.pc.mc.PortletApplicationDeployer.onEvent(PortletApplicationDeployer.java:185)  at org.gatein.wci.impl.DefaultServletContainer.safeFireEvent(DefaultServletContainer.java:200)  at org.gatein.wci.impl.DefaultServletContainer.fireEvent(DefaultServletContainer.java:219)  at org.gatein.wci.impl.DefaultServletContainer.access$400(DefaultServletContainer.java:60)  at org.gatein.wci.impl.DefaultServletContainer$RegistrationImpl.registerWebApp(DefaultServletContainer.java:338)  at org.gatein.wci.tomcat.TC7ServletContainerContext.start(TC7ServletContainerContext.java:380)  at org.gatein.wci.tomcat.TC7ServletContainerContext.lifecycleEvent(TC7ServletContainerContext.java:234)  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)  at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)  at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  at java.lang.Thread.run(Thread.java:619)

 

 

There were a few steps to do to update from Tomcat 6 to 7 - several errors which could be solved by adding or removing jars from the poms.xml. Then I ran into the problem that my entry in the web.xml of the project was outdated. I replaced the Tomcat 6 dependencies by Tomcat 7 dependencies:

 

<servlet>

        <servlet-name>ContainerServlet</servlet-name>

        <servlet-class>org.gatein.wci.tomcat.TC7ContainerServlet</servlet-class>

        <load-on-startup>1</load-on-startup>

</servlet>

 

Clearly the TC6ContainerServlet was replaced by the TC7ContainerServlet, which can be found in the following jar: wci-tomcat7-2.1.1-GA.jar

 

When I debug the application I enter in the following class:

 

package org.gatein.pc.portlet.impl.jsr168;

 

public class ClassInstanceLifeCycle<T> {

...

public void create() throws PortletInitializationException

   {

      T instance;

      try

      {

         Class clazz = classLoader.loadClass(className);

         if (expectedClass.isAssignableFrom(clazz))

         {

            Class<? extends T> castedClass = clazz.asSubclass(expectedClass);

            Constructor<? extends T> ctor = castedClass.getConstructor();

            instance = ctor.newInstance();

         }

...

}

 

The entries in red are of the following types:

className: com.qnamic.railopt.web.security.portlet.PortletSecurityFilter

expectedClass: javax.portlet.filter.PortletFilter

 

The problem is now that the call isAssignableFrom(..) fails! and an exception is thrown.

 

The error message claims that the class PortletSecurityFilter doesn't implement the PortletFilter interface. But it does:

 

public class PortletSecurityFilter implements ActionFilter, EventFilter, RenderFilter, ResourceFilter {

...//code here

}


ActionFilter is an extension of PortletFilter.

 

The package structure is as follows:

RailOptWebAbsence : Contains the portlet that should be run on the portal and throws the exception

 

Dependencies:

 

- RailOptWebSecurity

- RailOptWebCommunicator

- RailOptWebPortletBridge

- RailOptWebCommunicator

 

which contains no additional jars.

 

The classloader is the webappclassloader /RailOptWebAbsence. The library portlet-api-2.0.jar is contained as jar in RailOptWebAbsence.

I use the following gatein jars:

 

- pc-portlet-2.3.1-GA.jar

- pc-mc-2.3.0-Beta04.jar

- pc-controller-2.3.1-GA.jar

- pc-api-2.3.1-GA.jar

- wci-wci-2.1.1-GA.jar

- wci-tomcat7-2.1.1-GA.jar

 

These libraries are part of JBoss Gatein 3.2!

 

Since I work with Spring I have defined an applicationContext-gatein.xml which is referenced by the applicationContext.xml in the project:

 

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd

        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

 

    <bean id="PortletApplicationDeployer" class="org.gatein.pc.mc.PortletApplicationDeployer"

        init-method="start" destroy-method="stop">

        <property name="servletContainerFactory">

            <ref bean="ServletContainerFactory" />

        </property>

        <property name="containerPortletInvoker">

            <ref bean="ContainerPortletInvoker" />

        </property>

    </bean>

 

    <alias name="PortletApplicationDeployer" alias="PortletApplicationRegistry" />

 

    <!-- The ServletContainerFactory -->

    <bean name="ServletContainerFactory" class="org.gatein.wci.impl.DefaultServletContainerFactory"

        factory-method="getInstance">

    </bean>

 

    <!-- The servlet container obtained from the ServletContainerFactory -->

    <bean name="ServletContainer" factory-bean="ServletContainerFactory"

        factory-method="getServletContainer" class="org.gatein.wci.ServletContainer">

    </bean>

 

    <!-- The producer persistence manager -->

    <bean name="ProducerPersistenceManager"

        class="org.gatein.pc.portlet.impl.state.producer.PortletStatePersistenceManagerService" />

 

    <!-- The producer state management policy -->

    <bean name="ProducerStateManagementPolicy"

        class="org.gatein.pc.portlet.impl.state.StateManagementPolicyService">

        <property name="persistLocally">

            <value>false</value>

        </property>

    </bean>

 

    <!-- The producer state converter -->

    <bean name="ProducerStateConverter"

        class="com.qnamic.railopt.web.portal.gatein.GateInStateConverter" />

 

    <!-- The consumer portlet invoker -->

    <bean name="ConsumerPortletInvoker" class="org.gatein.pc.portlet.PortletInvokerInterceptor">

        <property name="next">

            <ref bean="ConsumerCacheInterceptor" />

        </property>

    </bean>

    <bean name="ConsumerCacheInterceptor"

        class="org.gatein.pc.portlet.aspects.ConsumerCacheInterceptor">

        <property name="next">

            <ref bean="PortletCustomizationInterceptor" />

        </property>

    </bean>

    <bean name="PortletCustomizationInterceptor"

        class="org.gatein.pc.portlet.aspects.PortletCustomizationInterceptor">

        <property name="next">

            <ref bean="ProducerPortletInvoker" />

        </property>

    </bean>

 

    <!-- The producer portlet invoker -->

    <bean name="ProducerPortletInvoker"

        class="org.gatein.pc.portlet.state.producer.ProducerPortletInvoker">

        <property name="next">

            <ref bean="ContainerPortletInvoker" />

        </property>

        <property name="persistenceManager">

            <ref bean="ProducerPersistenceManager" />

        </property>

        <property name="stateManagementPolicy">

            <ref bean="ProducerStateManagementPolicy" />

        </property>

        <property name="stateConverter">

            <ref bean="ProducerStateConverter" />

        </property>

    </bean>

 

    <!-- The portlet container invoker -->

    <bean name="ContainerPortletInvoker"

        class="org.gatein.pc.portlet.container.ContainerPortletInvoker">

        <property name="next">

            <ref bean="ValveInterceptor" />

        </property>

    </bean>

 

    <!-- Container stack -->

    <bean name="ValveInterceptor" class="org.gatein.pc.portlet.aspects.ValveInterceptor">

        <property name="portletApplicationRegistry">

            <ref bean="PortletApplicationRegistry" />

        </property>

        <property name="next">

            <ref bean="SecureTransportInterceptor" />

        </property>

    </bean>

    <bean name="SecureTransportInterceptor"

        class="org.gatein.pc.portlet.aspects.SecureTransportInterceptor">

        <property name="next">

            <ref bean="ContextDispatcherInterceptor" />

        </property>

    </bean>

    <bean name="ContextDispatcherInterceptor"

        class="org.gatein.pc.portlet.aspects.ContextDispatcherInterceptor">

        <property name="servletContainerFactory">

            <ref bean="ServletContainerFactory" />

        </property>

        <property name="next">

            <ref bean="ProducerCacheInterceptor" />

        </property>

    </bean>

    <bean name="ProducerCacheInterceptor"

        class="org.gatein.pc.portlet.aspects.ProducerCacheInterceptor">

        <property name="next">

            <ref bean="CCPPInterceptor" />

        </property>

    </bean>

    <bean name="CCPPInterceptor" class="org.gatein.pc.portlet.aspects.CCPPInterceptor">

        <property name="next">

            <ref bean="RequestAttributeConversationInterceptor" />

        </property>

    </bean>

    <bean name="RequestAttributeConversationInterceptor"

        class="org.gatein.pc.portlet.aspects.RequestAttributeConversationInterceptor">

        <property name="next">

            <ref bean="EventPayloadInterceptor" />

        </property>

    </bean>

    <bean name="EventPayloadInterceptor" class="org.gatein.pc.portlet.aspects.EventPayloadInterceptor">

        <property name="next">

            <ref bean="PortletContainerDispatcher" />

        </property>

    </bean>

    <bean name="PortletContainerDispatcher"

        class="org.gatein.pc.portlet.container.ContainerPortletDispatcher">

    </bean>

</beans>

 

The referenced classes which will be injected by the Spring framework are fully loaded (Tomcat info messages)!

I don't now if there are needed more informations. If yes let me now!