`
can4you
  • 浏览: 101429 次
  • 性别: Icon_minigender_1
  • 来自: 天朝
社区版块
存档分类
最新评论

Tomcat6.x部署MyFaces包冲突问题

阅读更多

项目环境:JSF2.0(MyFaces2.0.1)+RichFaces+Tomahawk1.1.9+Spring2.0+Hibernate3.2.x

(附apache官网上说tomahawk只支持到JSF1.2,但是我在JSF2.0的环境下测试可用,不知道后续是否会有问题

 

启动Tomcat的时候报以下错误,百思不得其解

 

INFO [main] [2010-09-25 15:14:53,375] (org.springframework.orm.hibernate3.HibernateTransactionManager) - Using DataSource [org.apache.commons.dbcp.BasicDataSource@1739f] of Hibernate SessionFactory for HibernateTransactionManager
 INFO [main] [2010-09-25 15:14:53,750] (org.springframework.aop.framework.DefaultAopProxyFactory) - CGLIB2 available: proxyTargetClass feature enabled
 INFO [main] [2010-09-25 15:14:54,796] (org.springframework.web.context.ContextLoader) - Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for root WebApplicationContext
 INFO [main] [2010-09-25 15:14:54,796] (org.springframework.web.context.ContextLoader) - Root WebApplicationContext: initialization completed in 24203 ms
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getLongInitParameter
信息: No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.VIEWSTATE_JAVASCRIPT' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getStringInitParameter
信息: No context init parameter 'org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS' found, using default value auto
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.VALIDATE_XML' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.DETECT_JAVASCRIPT' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.AUTO_SCROLL' found, using default value false
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getStringInitParameter
信息: No context init parameter 'org.apache.myfaces.ADD_RESOURCE_CLASS' found, using default value org.apache.myfaces.renderkit.html.util.DefaultAddResource
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getStringInitParameter
信息: No context init parameter 'org.apache.myfaces.RESOURCE_VIRTUAL_PATH' found, using default value /faces/myFacesExtensionResource
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
信息: No context init parameter 'org.apache.myfaces.CHECK_EXTENSIONS_FILTER' found, using default value true
2010-9-25 15:14:55 org.apache.myfaces.shared_impl.config.MyfacesConfig createAndInitializeMyFacesConfig
信息: Starting up Tomahawk on the MyFaces-JSF-Implementation
2010-9-25 15:14:55 org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
严重: An error occured while initializing MyFaces: null
java.lang.NullPointerException
 at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:62)
 at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:116)
 at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:106)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
 INFO [main] [2010-09-25 15:14:55,968] (org.springframework.orm.hibernate3.support.OpenSessionInViewFilter) - Initializing filter 'openSession'
 INFO [main] [2010-09-25 15:14:56,046] (org.springframework.orm.hibernate3.support.OpenSessionInViewFilter) - Filter 'openSession' configured successfully
 WARN [main] [2010-09-25 15:14:56,421] (org.ajax4jsf.webapp.BaseXMLFilter) - This version of RichFaces implementation compatible for JSF2.0, but running under JSF1.2
 INFO [main] [2010-09-25 15:14:56,578] (org.ajax4jsf.cache.CacheManager) - Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
 INFO [main] [2010-09-25 15:14:56,609] (org.ajax4jsf.cache.LRUMapCacheFactory) - Creating LRUMap cache instance using parameters: {org.ajax4jsf.VIEW_HANDLERS=org.apache.myfaces.application.jsp.JspViewHandlerImpl, javax.faces.CONFIG_FILES=/WEB-INF/conf/faces-config.xml, /WEB-INF/conf/faces-beans.xml, /WEB-INF/conf/faces-navigation.xml, contextConfigLocation=classpath:spring/applicationContext-db.xml, classpath:spring/applicationContext*.xml}
 INFO [main] [2010-09-25 15:14:56,609] (org.ajax4jsf.cache.LRUMapCacheFactory) - Creating LRUMap cache instance of default capacity
 INFO [main] [2010-09-25 15:14:56,906] (org.ajax4jsf.cache.CacheManager) - Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
 INFO [main] [2010-09-25 15:14:56,906] (org.ajax4jsf.cache.LRUMapCacheFactory) - Creating LRUMap cache instance using parameters: {org.ajax4jsf.VIEW_HANDLERS=org.apache.myfaces.application.jsp.JspViewHandlerImpl, javax.faces.CONFIG_FILES=/WEB-INF/conf/faces-config.xml, /WEB-INF/conf/faces-beans.xml, /WEB-INF/conf/faces-navigation.xml, contextConfigLocation=classpath:spring/applicationContext-db.xml, classpath:spring/applicationContext*.xml}
 INFO [main] [2010-09-25 15:14:56,906] (org.ajax4jsf.cache.LRUMapCacheFactory) - Creating LRUMap cache instance of default capacity
2010-9-25 15:14:56 org.apache.catalina.core.ApplicationContext log
严重: StandardWrapper.Throwable
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

 at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:172)
 at javax.faces.webapp.FacesServlet.init(FacesServlet.java:112)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2010-9-25 15:14:56 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /tcbflow threw load() exception
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

 at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:172)
 at javax.faces.webapp.FacesServlet.init(FacesServlet.java:112)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2010-9-25 15:14:57 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2010-9-25 15:14:57 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2010-9-25 15:14:57 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/187  config=null
2010-9-25 15:14:57 org.apache.catalina.startup.Catalina start
信息: Server startup in 33030 ms

 

 

最后解决方式:删除项目lib下的el-api.jar、servlet-api.jar后启动Tomcat

原因:tomcat6.x下的lib包中已经包括了这两个jar包(见图2),即常见的包冲突问题

 

有人会问:把这两个jar包从classpath中remove掉就不行了么?

 

因为项目中有用到以下代码:

UICommand command = (UICommand) actionEvent.getComponent();
MethodExpression methodExpression = command.getActionExpression();

依赖el-api.jar;

public class DefaultApplicationSetupListener implements ServletContextListener {

	public void contextInitialized(ServletContextEvent event) {
		SpringContainer container = new SpringContainer(event.getServletContext());
		Application.getInstance().setContainer(container);
	}

	public void contextDestroyed(ServletContextEvent arg0) {
	}

}

 

依赖servlet-api.jar;所以不能删除掉。

 

(注:java编译期不能依赖tomcat下的jar包,启动tomcat的时候又会发生jar包冲突,如果项目最后要部署在tomcat下,则可以在打包部署的时候通过Ant来有选择的添加依赖的jar包)

  • 大小: 77.7 KB
  • 大小: 24 KB
分享到:
评论

相关推荐

    com.springsource.org.apache.myfaces-1.1.5.jar

    jar包,官方版本,自测可用

    myfaces-core-assembly-2.2.7-bin.zip

    6. **部署和使用**: 要在项目中使用MyFaces,你需要将这些JAR文件添加到你的类路径中,并在web.xml配置文件中指定MyFaces作为JSF实现。如果你使用的是Maven或其他依赖管理工具,可以通过指定相应的依赖来简化这个...

    jsf配置myfaces各种jar

    本人用的是Myeclipse7.0+J2EE5.0+JSF开发,配置myfaces各种jar,包括上传.考到lib下就可以.哪里不明加我QQ问我 200808006

    jmock-1.2.0.jar

    Maven-Central / org.apache.myfaces.core / myfaces-api 2.1.72.1.62.1.52.1.42.1.31.2.2 Maven-Central / org.apache.myfaces.core / myfaces-impl 2.1.72.1.62.1.52.1.42.1.31.2.10 Maven-Central / org.apache....

    MyFaces 上下文参数详解(中、英文)

    一、`org.apache.myfaces.SERIALIZE_STATE_IN_SESSION` 此参数控制MyFaces是否将组件状态存储在会话中。默认值为`true`,意味着组件状态会在每个请求之间序列化并存储在用户的会话中。如果设置为`false`,状态将...

    com.springsource.org.apache.myfaces.javax.faces-1.1.5.jar

    jar包,官方版本,自测可用

    com.springsource.org.apache.myfaces.javax.faces_1.2.2.jar

    jar包,官方版本,自测可用

    com.springsource.org.apache.myfaces-sources-1.1.5.jar

    jar包,官方版本,自测可用

    myfaces-all.jar.zip

    "myfaces-all.jar"是MyFaces的全集包,其中包含了MyFaces的所有核心模块和依赖。这些模块包括但不限于以下几个关键部分: 1. **核心API**:这是MyFaces的基础,提供了JSF框架的基本接口和类,如FacesContext、...

    myfaces-all-1.1.1.jar

    此外,随着技术的演进,更现代的MyFaces版本如2.x和3.x可能引入了更多功能和性能优化,对于新项目,选择较新的版本可能是更好的选择。 总之,myfaces-all-1.1.1.jar作为MyFaces框架的一个重要组成部分,它在Java ...

    javax.el-api-3.0.0.jar 解决tomcat7的el版本过低问题

    你需要同时提供一个EL 3.0的实现,如Apache Tomcat的开源实现"org.apache.myfaces.tomcat.el-3.0.x.jar",或者Oracle的"com.sun.el-2.2.0.jar"(尽管它实际上实现了EL 3.0,但仍然保持旧的包名,以兼容性为目的)。...

    myfaces-core-2.0.1-bin.zip

    MyFaces是Apache软件基金会开发的一个开源JavaServer Faces (JSF)实现项目,它提供了一整套用于构建Web应用程序的组件库和服务。MyFaces的核心库,也就是我们这里关注的`myfaces-core-2.0.1-bin.zip`,包含了运行JSF...

    myfaces-extcdi-jpa1-module-impl-1.0.6.zip

    【标题】"myfaces-extcdi-jpa1-module-impl-1.0.6.zip" 涉及的是一款名为 MyFaces 的开源项目扩展,它专注于整合CDI(Contexts and Dependency Injection)与JPA(Java Persistence API)的模块实现。这个版本号为...

    iceface-myfaces例子

    6. **部署与测试**:最后,将WAR文件部署到门户服务器,如Liferay、WebSphere Portal等,然后在门户环境中测试portlet的功能和性能。 通过深入研究“sample-icefaces-myfaces-portlet.war”,开发者不仅可以学习到...

    myfaces的jar包,是官网最新的。

    MyFaces是JavaServer Faces(JSF) Web框架 (JSR 127)的一个实现。JavaServer(tm) Faces Web框架是一个新的实现MVC模式的规范.它可以与Struts框架相媲美甚至的一些特性与观念已经超过了Struts.【FacesIDE:Eclipse下的...

    Apache MyFaces Scripting.zip

    8. **Tomcat兼容性**:由于Apache MyFaces是Apache的产品,它通常与Apache Tomcat这样的轻量级Servlet容器很好地集成,使得部署和调试更为方便。 9. **开发工具**:Eclipse, NetBeans, IntelliJ IDEA等IDE通常有对...

    JSF.rar_JSF_myfaces-all.j

    在这个"JSF.rar"压缩包中,我们关注的是"JSF_myfaces-all.j",这可能是指MyFaces库的一个组件,MyFaces是JSF规范的一种实现。 JSF的核心概念包括组件、事件和渲染。组件是JSF应用的基本构建块,它们可以是简单的...

    jsf2.0源碼(myfaces2.0.4 api+impl)

    通过深入学习MyFaces 2.0.4的API和Impl源码,开发者可以更好地理解JSF的工作机制,提升开发效率,解决实际问题,同时为定制和优化JSF应用打下坚实基础。无论是对框架的维护、性能优化,还是为了提高代码质量,理解...

    myfaces-example-tiles-1.1.6.rar_Tiles_myfaces examp_myfaces-exam

    6. "WEB-INF" - 标准的Web应用目录,包含web.xml(Web应用部署描述符)和其他库文件(如JARs)。 7. "common" - 可能包含了一些通用的资源或组件,如JavaScript文件或共用的JSP片段。 8. "template" - 这个目录可能...

    myfaces-example-tiles-1.1.6.rar_Tiles_jsf myfaces_jsf tiles exam

    5. **实践应用部署**:了解如何将这个例子部署到Servlet容器,如Tomcat或Jetty,并进行测试。 通过深入研究这个示例,开发者可以更好地理解如何在实际项目中结合使用JSF和Tiles,提升Web应用的结构化和可维护性。

Global site tag (gtag.js) - Google Analytics