JSF 2.2 webapp works on Local Machine but not on the Server

老子叫甜甜 提交于 2019-12-11 18:44:00

问题


I am trying to create a web application using jsf 2.2. My application is using JERSEY Restful, jre 1.8, JSF 2.2, Primefaces.

It works perfectly fine on my local machine but on AWS(EC2- Tomcat by bitnami-free tier) I get the error(Error log at the bottom.)

Thank you so much for your help in Advance.

I'm using the following libraries

Here's my Web.xml file code:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>MYAPP</display-name>
 <welcome-file-list>
    <welcome-file>welcome.jsf</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>Jersey Rest Service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey Rest Service</servlet-name>
    <url-pattern>/webresources/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
</web-app>

Error Log 26-Apr-2018 03:33:43.130 SEVERE [localhost-startStop-23] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.sun.faces.config.ConfigureListener] java.lang.RuntimeException: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at com.sun.faces.config.ConfigureListener.contextInitialized(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at org.primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27) at org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48) at javax.faces.event.SystemEvent.processListener(Unknown Source) at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source) at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source) at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source) at com.sun.faces.config.ConfigManager.publishPostConfigEvent(Unknown Source) ... 14 more

26-Apr-2018 03:33:43.463 SEVERE [localhost-startStop-23] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.sun.faces.config.ConfigureListener] java.lang.RuntimeException: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at com.sun.faces.config.ConfigureListener.contextInitialized(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at org.primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27) at org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48) at javax.faces.event.SystemEvent.processListener(Unknown Source) at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source) at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source) at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source) at com.sun.faces.config.ConfigManager.publishPostConfigEvent(Unknown Source) ... 14 more

26-Apr-2018 03:39:45.299 SEVERE [localhost-startStop-24] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.sun.faces.config.ConfigureListener] java.lang.RuntimeException: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at com.sun.faces.config.ConfigureListener.contextInitialized(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at org.primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27) at org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48) at javax.faces.event.SystemEvent.processListener(Unknown Source) at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source) at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source) at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source) at com.sun.faces.config.ConfigManager.publishPostConfigEvent(Unknown Source) ... 14 more

26-Apr-2018 03:39:45.716 SEVERE [localhost-startStop-24] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.sun.faces.config.ConfigureListener] java.lang.RuntimeException: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at com.sun.faces.config.ConfigureListener.contextInitialized(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at org.primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27) at org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48) at javax.faces.event.SystemEvent.processListener(Unknown Source) at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source) at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source) at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source) at com.sun.faces.config.ConfigManager.publishPostConfigEvent(Unknown Source) ... 14 more

26-Apr-2018 04:57:18.310 SEVERE [localhost-startStop-25] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.sun.faces.config.ConfigureListener] java.lang.RuntimeException: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at com.sun.faces.config.ConfigureListener.contextInitialized(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoSuchMethodError: javax.faces.application.Application.addSearchKeywordResolver(Ljavax/faces/component/search/SearchKeywordResolver;)V at org.primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27) at org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48) at javax.faces.event.SystemEvent.processListener(Unknown Source) at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source) at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source) at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source) at com.sun.faces.config.ConfigManager.publishPostConfigEvent(Unknown Source) ... 14 more


回答1:


You seem to include different versions of JSF in your project which causes the problem. I can see javax.faces-2.3.2 in your dependencies as well as jsf-api-2.2.9/jsf-impl-2.2.9. The method addSearchKeywordResolver in javax.faces.application.Application is called and can't be found (as the stack trace tells you). This method is only part of JSF 2.3. However the JSF 2.2 class seems to be used. The method is called by PrimeFaces because PrimeFaces thinks you are using JSF 2.3 because the class javax.faces.component.UIImportConstants can be found in the class path (in javax.faces-2.3.2 dependency). I think the solution is only to include depedencies of one JSF version.



来源:https://stackoverflow.com/questions/50035343/jsf-2-2-webapp-works-on-local-machine-but-not-on-the-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!