首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Tomcat6.x部署MyFaces包冲突有关问题

2012-09-16 
Tomcat6.x部署MyFaces包冲突问题项目环境:JSF2.0(MyFaces2.0.1)+RichFaces+Tomahawk1.1.9+Spring2.0+Hiber

Tomcat6.x部署MyFaces包冲突问题

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

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

?

启动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掉就不行了么?

?

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

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包)

热点排行