1

I tried to run Tomcat with JSF 2.3.0-m05 but I get error

java.lang.NoSuchMethodError: javax.faces.view.facelets.FaceletCache.setCacheFactories(Ljavax/faces/view/facelets/FaceletCache$MemberFactory;Ljavax/faces/view/facelets/FaceletCache$MemberFactory;)V

Full log file: http://pastebin.com/UkhQ3L5D
Maven pom.xml: http://pastebin.com/P4ZJYm5v

Is there any solution or is this a known issue?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • That can happen if the runtime classpath is polluted with multiple different versioned JSF libraries. Just get rid of other versions. – BalusC Apr 05 '16 at 18:49
  • I only changed maven dependency in POM file: http://pastebin.com/P4ZJYm5v Maybe I need to upgrade some jar file in tomcat's lib folder? – Peter Penzov Apr 05 '16 at 18:52

1 Answers1

3

java.lang.NoSuchMethodError: javax.faces.view.facelets.FaceletCache.setCacheFactories(Ljavax/faces/view/facelets/FaceletCache$MemberFactory;Ljavax/faces/view/facelets/FaceletCache$MemberFactory;)V

This method is new since JSF 2.3. This problem thus suggests you've an older JSF API version in runtime classpath.

Based on your pom.xml, the following dependencies are conflicting:

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>javax.faces-api</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>7.0</version>
</dependency>

The first represents the JSF 2.2 API (which is only the javax.faces.* part of Java EE 7 API). Remove it altogether. The JSF 2.3 dependency has its own set already.

The second represents the entire Java EE 7 API, including JSF 2.2, Servlet 3.1, EL 3.0, CDI 1.1, JAX-RS 1.0, JSONP 1.0, etc. This one may absolutely not end up in webapp's runtime classpath. This one is supposed to be provided by the target runtime already. You need to mark it provided.

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
</dependency>

This is actually misleading when you're instead of a real Java EE server targeting a barebones servletcontainer such as Tomcat 8.0, which only ships JSP 2.3, Servlet 3.1, EL 3.0 and WebSockets 1.1 out the box. You're supposed to specify them all individually instead of the entire Java EE 7 API. Otherwise you must be careful while writing code that you don't accidentally import/use some parts of Java EE 7 API which are actually not provided by Tomcat such as JSF, JSTL, CDI, etc. You'd then need to explicitly provide them along with the webapp (as you already did for some parts).

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555