JSF 2.2 webapp适用于本地计算机,但不适用于服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JSF 2.2 webapp适用于本地计算机,但不适用于服务器相关的知识,希望对你有一定的参考价值。

我正在尝试使用jsf 2.2创建一个Web应用程序。我的应用程序使用JERSEY Restful,jre 1.8,JSF 2.2,Primefaces。

它在我的本地机器上完全正常,但在AWS(EC2- Tomcat by bitnami-free tier)上我收到错误(底部的错误日志。)

非常感谢你在Advance中提供的帮助。

我正在使用以下库

enter image description here

这是我的Web.xml文件代码:

<?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将上下文初始化事件发送到类[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来自org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)的org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)org.apache.catalina.util.LifecycleBase .start(LifecycleBase.java:150)org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)org。 org.apache.catalina.startup.HostConfi上的apache.catalina.core.StandardHost.addChild(StandardHost.java:734) g.deployWAR(HostConfig.java:986)atg.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)引起:java.lang.NoSuchMethodError:javax.faces.application.Application.addSearchKeywordResolver(Ljavax / faces / component / search / SearchKeywordResolver;)V at org.primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27)位于com的javax.faces.event.SystemEvent.processListener(未知来源)的org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48)。 com.sun.faces.application.ApplicationImp中的sun.faces.application.ApplicationImpl.processListeners(未知来源)来自com.sun.faces.application.ApplicationImpl.publishEvent(未知来源)的l.invokeListenersFor(未知来源)com.sun.faces.config.ConfigManager.publishPostConfigEvent(未知来源)... 14更多信息

201-Apr-2018 03:33:43.463 SEVERE [localhost-startStop-23] org.apache.catalina.core.StandardContext.listenerStart将上下文初始化事件发送到类[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) org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743)位于org.apache.catalina.util.LifecycleBase.start的org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) (LifecycleBase.java:150)位于org.apache的org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)。 catalina.core.StandardHost.addChild(StandardHost.java:734)at org.apache.catalina.startup.HostConfig.deployWA R(HostConfig.java:986)atg.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) )在java.lang.Thread.run(Thread.java:748)引起:java.lang.NoSuchMethodError:javax.faces.application.Application.addSearchKeywordResolver(Ljavax / faces / component / search / SearchKeywordResolver;)V at org。位于com.sun的javax.faces.event.SystemEvent.processListener(未知来源)的org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48)中的primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27)。 com.sun.faces.application.ApplicationImpl.invokeLi中的faces.application.ApplicationImpl.processListeners(未知来源)来自com.sun.faces.application.ApplicationImpl.publishEvent(未知来源)的stenersFor(未知来源)com.sun.faces.config.ConfigManager.publishPostConfigEvent(未知来源)... 14更多信息

201-Apr-2018 03:39:45.299 SEVERE [localhost-startStop-24] org.apache.catalina.core.StandardContext.listenerStart将上下文初始化事件发送到类[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) org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)位于org.apache.catalina.util.LifecycleBase.start的org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) (LifecycleBase.java:150)位于org.apache的org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)。 catalina.core.StandardHost.addChild(StandardHost.java:734)at org.apache.catalina.startup.HostConfig.deployWA R(HostConfig.java:986)atg.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) )在java.lang.Thread.run(Thread.java:748)引起:java.lang.NoSuchMethodError:javax.faces.application.Application.addSearchKeywordResolver(Ljavax / faces / component / search / SearchKeywordResolver;)V at org。位于com.sun的javax.faces.event.SystemEvent.processListener(未知来源)的org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48)中的primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27)。 com.sun.faces.application.ApplicationImpl.invokeLi中的faces.application.ApplicationImpl.processListeners(未知来源)来自com.sun.faces.application.ApplicationImpl.publishEvent(未知来源)的stenersFor(未知来源)com.sun.faces.config.ConfigManager.publishPostConfigEvent(未知来源)... 14更多信息

26-Apr-2018 03:39:45.716 SEVERE [localhost-startStop-24] org.apache.catalina.core.StandardContext.listenerStart将上下文初始化事件发送到类[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) org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743)位于org.apache.catalina.util.LifecycleBase.start的org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) (LifecycleBase.java:150)位于org.apache的org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)。 catalina.core.StandardHost.addChild(StandardHost.java:734)at org.apache.catalina.startup.HostConfig.deployWA R(HostConfig.java:986)atg.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) )在java.lang.Thread.run(Thread.java:748)引起:java.lang.NoSuchMethodError:javax.faces.application.Application.addSearchKeywordResolver(Ljavax / faces / component / search / SearchKeywordResolver;)V at org。位于com.sun的javax.faces.event.SystemEvent.processListener(未知来源)的org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48)中的primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27)。 com.sun.faces.application.ApplicationImpl.invokeLi中的faces.application.ApplicationImpl.processListeners(未知来源)来自com.sun.faces.application.ApplicationImpl.publishEvent(未知来源)的stenersFor(未知来源)com.sun.faces.config.ConfigManager.publishPostConfigEvent(未知来源)... 14更多信息

26-Apr-2018 04:57:18.310 SEVERE [localhost-startStop-25] org.apache.catalina.core.StandardContext.listenerStart将上下文初始化事件发送到类[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) org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743)位于org.apache.catalina.util.LifecycleBase.start的org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) (LifecycleBase.java:150)位于org.apache的org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)。 catalina.core.StandardHost.addChild(StandardHost.java:734)at org.apache.catalina.startup.HostConfig.deployWA R(HostConfig.java:986)atg.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) )在java.lang.Thread.run(Thread.java:748)引起:java.lang.NoSuchMethodError:javax.faces.application.Application.addSearchKeywordResolver(Ljavax / faces / component / search / SearchKeywordResolver;)V at org。位于com.sun的javax.faces.event.SystemEvent.processListener(未知来源)的org.primefaces.webapp.PostConstructApplicationEventListener.processEvent(PostConstructApplicationEventListener.java:48)中的primefaces.util.Jsf23Helper.addSearchKeywordResolvers(Jsf23Helper.java:27)。 com.sun.faces.application.ApplicationImpl.invokeLi中的faces.application.ApplicationImpl.processListeners(未知来源)来自com.sun.faces.application.ApplicationImpl.publishEvent(未知来源)的stenersFor(未知来源)com.sun.faces.config.ConfigManager.publishPostConfigEvent(未知来源)... 14更多信息

答案

您似乎在项目中包含了导致问题的不同版本的JSF。我可以在你的依赖项中看到javax.faces-2.3.2以及jsf-api-2.2.9 / jsf-impl-2.2.9。调用javax.faces.application.Application中的方法addSearchKeywordResolver并且找不到(如堆栈跟踪告诉你的那样)。此方法只是JSF 2.3的一部分。但是似乎使用了JSF 2.2类。该方法由PrimeFaces调用,因为PrimeFaces认为您使用的是JSF 2.3,因为类javax.faces.component.UIImportConstants可以在类路径中找到(在javax.faces-2.3.2依赖项中)。我认为解决方案只包括一个JSF版本的依赖项。

以上是关于JSF 2.2 webapp适用于本地计算机,但不适用于服务器的主要内容,如果未能解决你的问题,请参考以下文章

vue中将汉字按照首字母排序,也适用于其他地方,但不适用多音字

如何在 Oracle Weblogic 12.1 中部署 JSF 2.1 webapp?

在 JSF 中 - 获取客户端的区域设置(在浏览器的时区中显示时间)

oledb.12.0 提供程序未在本地计算机上注册,但适用于某些应用程序

部分视图部分适用于 JQuery,但不完全适用于 C# ASP.Net MVC 5

将基于 Maven 的 JSF 项目部署到 Tomcat 会导致 java.lang.ClassNotFoundException:javax.faces.webapp.FacesServlet [重