0

I have a web project using JSF 1.1 that I want to upgrade to version 2.2. I want to perform this upgrade step by step, first concentrating on upgrading JSF itself before replacing old taglibs (I plan to replace RichFaces and Ajax4JSF with PrimeFaces) and then the view technology from JSP to Facelets.

Generally, I have been following the advice by BalusC from Migrating from JSF 1.1 to JSF 1.2 and Migrating from JSF 1.2 to JSF 2.0 After updating the faces-config.xml and the web.xml they way described in that post, I wanted to update the JSF implementation itself. Since I use Maven I didn't drop the new jars into the WEB-INF/lib directory of the webapp manually but instead updated the corresponding part in the pom.xml like follows from

<dependency>
  <groupId>org.apache.myfaces.core</groupId>
  <artifactId>myfaces-api</artifactId>
  <version>1.1.5</version>
</dependency>
<dependency>
  <groupId>org.apache.myfaces.core</groupId>
  <artifactId>myfaces-impl</artifactId>
  <version>1.1.5</version>
</dependency>

to

<dependency>
  <groupId>org.apache.myfaces.core</groupId>
  <artifactId>myfaces-api</artifactId>
  <version>2.2.12</version>
</dependency>
<dependency>
  <groupId>org.apache.myfaces.core</groupId>
  <artifactId>myfaces-impl</artifactId>
  <version>2.2.12</version>
</dependency>

As webserver I use Tomcat 7 (which gets started via maven plugin from IntelliJ). After upgrading the MyFaces libraries this way, I now get the following NoClassDefFoundError with the following stack trace:

SEVERE: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NoClassDefFoundError: javax/portlet/RenderResponse
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.apache.catalina.util.Introspection.getDeclaredMethods(Introspection.java:127)
    at org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache(DefaultInstanceManager.java:342)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:161)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:155)
    at org.apache.myfaces.spi.impl.Tomcat7AnnotationInjectionProvider.postConstruct(Tomcat7AnnotationInjectionProvider.java:94)
    at org.apache.myfaces.config.FacesConfigurator.configureLifecycle(FacesConfigurator.java:1392)
    at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:605)
    at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:416)
    at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)
    at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:172)
    at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:121)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: javax.portlet.RenderResponse
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    ... 23 more

Now, I have seen similar problems being posted on SO here and here, but it seems to me that my problem is somewhat different, since the webapp worked correctly - without manually providing the myfaces-jars but rather managing them via maven - with the given Tomcat before upgrading to MyFaces 2.2.

When builing the webapp, I also get the following output from maven:

INFORMATION: Artifact 'myfaces-api' was found in version '2.2.12' from path 'file:/C:/.m2/repository/org/apache/myfaces/core/myfaces-api/2.2.12/myfaces-api-2.2.12.jar'
INFORMATION: Artifact 'myfaces-impl' was found in version '2.2.12' from path 'file:/C:/.m2/repository/org/apache/myfaces/core/myfaces-impl/2.2.12/myfaces-impl-2.2.12.jar'

so I assume the Tomcat actually found those jars.

What else could be the reason for the error?

Edit: Here are the new dependencies that have been added via the upgrade to MyFaces 2.2:

  • myfaces-api:jar:2.2.12
    • geronimo-atinject_1.0_spec:jar:1.0
  • myfaces-impl:jar:2.2.12
    • commons-beanutils:jar:1.9.2

Edit 2: I just tried different version of MyFaces and it works up until the latest version of 2.1, which is 2.1.18! With the first version of 2.2 - 2.2.0 - the error described above occurs.

Is there any portlet related change between JSF 2.1 and JSF 2.2 that could cause this error?

Edit 3: The project consistes of several modules. I will list the complete list of imported dependencies here that I have after upgrading to MyFaces 2.2, as determined by executing the mvn dependency:list command in the root project:

  • ant:ant-optional:jar:1.5.1:compile
  • antlr:antlr:jar:2.7.7:compile
  • aopalliance:aopalliance:jar:1.0:compile
  • asm:asm:jar:3.1:compile
  • avalon-framework:avalon-framework:jar:4.1.5:compile
  • batik:batik-awt-util:jar:1.6-1:compile
  • batik:batik-ext:jar:1.6-1:compile
  • batik:batik-gui-util:jar:1.6-1:compile
  • batik:batik-util:jar:1.6-1:compile
  • bouncycastle:bcmail-jdk14:jar:138:compile
  • bouncycastle:bcprov-jdk14:jar:138:compile
  • c3p0:c3p0-oracle-thin-extras:jar:0.9.5.2:compile
  • cglib:cglib:jar:2.2:compile
  • com.exadel.htmLib:htmLib:jar:1.0:compile
  • com.googlecode.json-simple:json-simple:jar:1.1.1:compile
  • com.h2database:h2:jar:1.4.193:test
  • com.ibm.icu:icu4j:jar:2.6.1:compile
  • com.keypoint:png-encoder:jar:1.5:compile
  • com.lowagie:itext:jar:2.1.5:compile
  • com.mchange:c3p0:jar:0.9.2.1:compile
  • com.mchange:c3p0:jar:0.9.5.2:compile
  • com.mchange:mchange-commons-java:jar:0.2.11:compile
  • com.mchange:mchange-commons-java:jar:0.2.3.4:compile
  • com.sun.jersey.contribs:jersey-multipart:jar:1.12:compile
  • com.sun.jersey:jersey-client:jar:1.12:compile
  • com.sun.jersey:jersey-core:jar:1.12:compile
  • com.sun.jersey:jersey-json:jar:1.12:compile
  • com.sun.jersey:jersey-server:jar:1.12:compile
  • com.sun.jersey:jersey-servlet:jar:1.12:compile
  • com.sun.medialib.codec:clibwrapper_jiio:jar:1.2-daily:compile
  • com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
  • com.thoughtworks.xstream:xstream:jar:1.3.1:compile
  • commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
  • commons-beanutils:commons-beanutils:jar:1.7.0:compile
  • commons-beanutils:commons-beanutils:jar:1.8.3:compile
  • commons-cli:commons-cli:jar:1.2:compile
  • commons-codec:commons-codec:jar:1.2:compile
  • commons-codec:commons-codec:jar:1.3:compile
  • commons-collections:commons-collections:jar:3.2.1:compile
  • commons-collections:commons-collections:jar:3.2.2:compile
  • commons-configuration:commons-configuration:jar:1.6:compile
  • commons-dbcp:commons-dbcp:jar:1.4:compile
  • commons-dbutils:commons-dbutils:jar:1.3:compile
  • commons-digester:commons-digester:jar:1.8:compile
  • commons-discovery:commons-discovery:jar:0.4:compile
  • commons-el:commons-el:jar:1.0:compile
  • commons-fileupload:commons-fileupload:jar:1.2.1:compile
  • commons-httpclient:commons-httpclient:jar:3.1:compile
  • commons-io:commons-io:jar:1.4:compile
  • commons-jxpath:commons-jxpath:jar:1.2:compile
  • commons-lang:commons-lang:jar:2.4:compile
  • commons-lang:commons-lang:jar:2.6:compile
  • commons-logging:commons-logging:jar:1.1.1:compile
  • commons-net:commons-net:jar:3.2:compile
  • commons-pool:commons-pool:jar:1.5.4:compile
  • commons-validator:commons-validator:jar:1.1.4:compile
  • commons-validator:commons-validator:jar:1.3.1:compile
  • de.schlichtherle.io:truezip:jar:6.6:compile
  • dom4j:dom4j:jar:1.6.1:compile
  • gov.loc.mets:mets:jar:1.7:compile
  • gov.loc.mods:mods:jar:3.3:compile
  • javax.activation:activation:jar:1.1:compile
  • javax.mail:mail:jar:1.4.4:compile
  • javax.media:jai_codec:jar:1.1.2_01:compile
  • javax.media:jai_core:jar:1.1.2_01:compile
  • javax.media:jai_imageio:jar:1.0_01:compile
  • javax.servlet:jstl:jar:1.1.2:compile
  • javax.transaction:jta:jar:1.1:compile
  • javax.ws.rs:jsr311-api:jar:1.1.1:compile
  • javax.xml.bind:jaxb-api:jar:2.2.2:compile
  • javax.xml.stream:stax-api:jar:1.0-2:compile
  • jaxen:jaxen:jar:1.1.1:compile
  • jdom:jdom:jar:1.0:compile
  • jfree:jcommon:jar:1.0.0:compile
  • joda-time:joda-time:jar:2.3:compile
  • junit:junit:jar:4.10:compile
  • junit:junit:jar:4.3:test
  • log4j:log4j:jar:1.2.16:compile
  • mysql:mysql-connector-java:jar:5.1.38:compile
  • net.sf.barcode4j:barcode4j-fop-ext-complete:jar:2.0:compile
  • net.sf.ehcache:ehcache:jar:1.2:compile
  • net.sf.j2ep:j2ep:jar:1.0:compile
  • net.sf.jsfcomp.chartcreator:chartcreator:jar:RC1:1.2.0:compile
  • net.sf.jsfcomp.easysi:easysi:jar:0.9.0:compile
  • net.xeoh:plugins-base:jar:1.0.0:compile
  • opensymphony:oscache:jar:2.3:compile
  • opensymphony:quartz-all:jar:1.6.5:compile
  • org.apache.activemq.protobuf:activemq-protobuf:jar:1.1:compile
  • org.apache.activemq:activeio-core:jar:3.1.2:compile
  • org.apache.activemq:activemq-core:jar:5.5.1:compile
  • org.apache.activemq:kahadb:jar:5.5.1:compile
  • org.apache.avalon.framework:avalon-framework-api:jar:4.3.1:compile
  • org.apache.commons:commons-compress:jar:1.4:compile
  • org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:compile
  • org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
  • org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0:compile
  • org.apache.httpcomponents:httpasyncclient:jar:4.1.2:compile
  • org.apache.httpcomponents:httpclient:jar:4.5.2:compile
  • org.apache.httpcomponents:httpcore-nio:jar:4.4.5:compile
  • org.apache.httpcomponents:httpcore:jar:4.4.5:compile
  • org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
  • org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
  • org.apache.lucene:lucene-analyzers:jar:3.0.2:compile
  • org.apache.lucene:lucene-core:jar:3.0.2:compile
  • org.apache.myfaces.core:myfaces-api:jar:2.1.18:compile
  • org.apache.myfaces.core:myfaces-impl:jar:2.1.18:compile
  • org.apache.myfaces.tomahawk:tomahawk-sandbox20:jar:1.1.10-SNAPSHOT:compile
  • org.apache.myfaces.tomahawk:tomahawk20:jar:1.1.14:compile
  • org.apache.pdfbox:fontbox:jar:1.7.1:compile
  • org.apache.pdfbox:jempbox:jar:1.7.1:compile
  • org.apache.pdfbox:pdfbox:jar:1.7.1:compile
  • org.apache.poi:poi-contrib:jar:3.6:compile
  • org.apache.poi:poi-ooxml-schemas:jar:3.6:compile
  • org.apache.poi:poi-ooxml:jar:3.6:compile
  • org.apache.poi:poi-scratchpad:jar:3.6:compile
  • org.apache.poi:poi:jar:3.6:compile
  • org.apache.tomcat:tomcat-servlet-api:jar:7.0.68:provided
  • org.apache.xmlbeans:xmlbeans:jar:2.4.0:compile
  • org.apache.xmlgraphics:batik-anim:jar:1.7:compile
  • org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile
  • org.apache.xmlgraphics:batik-bridge:jar:1.7:compile
  • org.apache.xmlgraphics:batik-css:jar:1.7:compile
  • org.apache.xmlgraphics:batik-dom:jar:1.7:compile
  • org.apache.xmlgraphics:batik-ext:jar:1.7:compile
  • org.apache.xmlgraphics:batik-extension:jar:1.7:compile
  • org.apache.xmlgraphics:batik-gvt:jar:1.7:compile
  • org.apache.xmlgraphics:batik-js:jar:1.7:compile
  • org.apache.xmlgraphics:batik-parser:jar:1.7:compile
  • org.apache.xmlgraphics:batik-script:jar:1.7:compile
  • org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
  • org.apache.xmlgraphics:batik-svggen:jar:1.7:compile
  • org.apache.xmlgraphics:batik-transcoder:jar:1.7:compile
  • org.apache.xmlgraphics:batik-util:jar:1.7:compile
  • org.apache.xmlgraphics:batik-xml:jar:1.7:compile
  • org.apache.xmlgraphics:fop:jar:0.95:compile
  • org.apache.xmlgraphics:xmlgraphics-commons:jar:1.3.1:compile
  • org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
  • org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile
  • org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
  • org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
  • org.codehaus.jettison:jettison:jar:1.1:compile
  • org.elasticsearch.client:rest:jar:5.1.1:compile
  • org.freemarker:freemarker:jar:2.3.10:compile
  • org.hamcrest:hamcrest-core:jar:1.1:compile
  • org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
  • org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
  • org.hibernate:hibernate-c3p0:jar:4.3.11.Final:compile
  • org.hibernate:hibernate-core:jar:4.3.11.Final:compile
  • org.jasypt:jasypt:jar:1.7:compile
  • org.javassist:javassist:jar:3.18.1-GA:compile
  • org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
  • org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
  • org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
  • org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
  • org.jboss:jandex:jar:1.1.0.Final:compile
  • org.jenia.faces:jenia4faces:jar:1.2.1:compile
  • org.jfree:jcommon:jar:1.0.23:compile
  • org.jfree:jfreechart:jar:1.0.19:compile
  • org.jvnet:mimepull:jar:1.6:compile
  • org.marc4j:marc4j:jar:1.0:compile
  • org.mockito:mockito-all:jar:2.0.2-beta:test
  • org.osgi:org.osgi.core:jar:4.1.0:compile
  • org.richfaces.framework:richfaces-api:jar:3.1.6.GA:compile
  • org.richfaces.framework:richfaces-impl:jar:3.1.6.GA:compile
  • org.richfaces.ui:richfaces-ui:jar:3.1.6.GA:compile
  • org.saxon:saxon9-dom:jar:9.0.0.4:compile
  • org.saxon:saxon9:jar:9.0.0.4:compile
  • org.slf4j:slf4j-api:jar:1.7.21:compile
  • org.slf4j:slf4j-simple:jar:1.7.21:compile
  • org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
  • org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
  • org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
  • org.springframework:spring-context:jar:3.0.3.RELEASE:compile
  • org.springframework:spring-core:jar:3.0.3.RELEASE:compile
  • org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
  • org.springframework:spring:jar:2.0.1:compile
  • org.tukaani:xz:jar:1.0:compile
  • oro:oro:jar:2.0.8:compile
  • poi:poi:jar:2.5.1-final-20040804:compile
  • stax:stax-api:jar:1.0.1:compile
  • taglibs:standard:jar:1.1.2:compile
  • xalan:xalan:jar:2.6.0:compile
  • xerces:xercesImpl:jar:2.6.2:compile
  • xerces:xercesImpl:jar:2.9.1:compile
  • xerces:xmlParserAPIs:jar:2.6.2:compile
  • xml-apis:xml-apis-ext:jar:1.3.04:compile
  • xml-apis:xml-apis:jar:1.0.b2:compile
  • xml-apis:xml-apis:jar:1.3.02:compile
  • xml-apis:xmlParserAPIs:jar:2.0.2:compile
  • xml-resolver:xml-resolver:jar:1.1:compile
  • xmlbeans:xbean_xpath:jar:2.4.0:compile
  • xom:xom:jar:1.0:compile
  • xpp3:xpp3:jar:1.1.3.3:compile
  • xpp3:xpp3_min:jar:1.1.4c:compile

Edit 4: I added the portlet-api via maven and now the error does not occur anymore. This is probably not a good solution but rather a workaround, but it alleviates the problem for now.

13
  • 2
    It looks like Maven has added a transitive dependency, which in turn depends on the Portlet api. Can you add the list of jars in your classpath? To get the effective list you can f.e. use Eclipse, by clicking the pom.xml and search the tabs in the opening window. Commented Mar 27, 2017 at 19:31
  • Indeed, Tomcat is not a portlet container, it's a servlet container. Commented Mar 28, 2017 at 6:38
  • I just compared the dependency tree generated by Maven before and after I added primefaces to the pom.xml and the only new dependency is org.primefaces:primefaces:jar:1.1. (no other transitive dependencies have been added, apparently) The project contains a lot of other jars which all have been part of the prior, working version using MyFaces 1.1, so I'd guess those jars didn't have any unsatisfiable portlet dependencies, right? Commented Mar 28, 2017 at 7:40
  • I just tried running the webapp with MyFaces 2.2 and without Primefaces, and it still raises the same error, so I guess it's not the primefaces artifacts fault either. Commented Mar 28, 2017 at 8:31
  • Sorry, I made a mistake when comparing the dependency trees before and after upgrading MyFaces to version 2.2. Added the new dependencies that were included after the upgrade to the main post. Commented Mar 28, 2017 at 9:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.