我使用Struts2的,春天和hibernate.I所面臨的struts.xml的文件有問題,它不採取它在applictioncontext.xml宣佈豆做一個項目。 我的applicationContext.xml看起來像這樣spring beans未在struts2中配置?
<bean id="dvdDAO" class="com.ideas2it.dvdstruts.DvdDAO">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="userDetailDAO" class="com.ideas2it.dvdstruts.UserDetailDAO">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hibernatetransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="DvdAction" class="com.ideas2it.dvdstruts.DvdAction" >
<property name="dvdDAO" ref="dvdDAO"/>
<property name="userDetailDAO" ref="userDetailDAO"/>
</bean>
<bean name="LoginAction" class="com.ideas2it.dvdstruts.LoginAction" >
<property name="userDetailDAO" ref="userDetailDAO"/>
</bean>
<bean name="AccountCreationAction" class="com.ideas2it.dvdstruts.AccountCreationAction" >
<property name="userDetailDAO" ref="userDetailDAO"/>
我在struts.xml
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.objectFactory" value="spring"/>
<package name="basicstruts2" namespace="/" extends="struts-default">
<action name="register" class="AccountCreationAction" method="register" >
<result name="success">Login.jsp</result>
<result name="input">failure.jsp</result>
</action>
<action name="login" class="LoginAction" method="loginProcess" >
<result name="success" type="redirectAction">
<param name="actionName">display</param>
<param name="userDetail">${userDetail}</param>
</result>
<result name="input">failure.jsp</result>
</action>
<action name="insert" class="DvdAction" method="insertDvd">
<result type="redirectAction">
<param name="actionName">display</param>
</result>
</action>
<action name="delete" class="DvdAction" method="deleteDvd">
<result type="redirectAction">
<param name="actionName">display</param>
</result>
</action>
<action name="update" class="DvdAction" method="updateDvd">
<result type="redirectAction">
<param name="actionName">display</param>
</result>
</action>
<action name="display" class="DvdAction" method="displayDvd">
<result name="success">Dvd.jsp</result>
</action>
</package>
</struts>
這是在applicationContext.xml中的豆未提到這兒過得上午收到錯誤日誌就像 錯誤日誌:
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
2012-12-14 10:22:09,821 INFO org.springframework.web.context.ContextLoader.initWebApplicationContext:187 - Root WebApplicationContext: initialization started
2012-12-14 10:22:09,901 INFO org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh:456 - Refreshing Root WebApplicationContext: startup date [Fri Dec 14 10:22:09 IST 2012]; root of context hierarchy
2012-12-14 10:22:09,999 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions:315 - Loading XML bean definitions from ServletContext resource [/WEB-INF/config/dvdstruts-context.xml]
2012-12-14 10:22:10,173 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions:315 - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/struts.xml]
2012-12-14 10:22:11,644 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons:555 - Pre-instantiating singletons in org.s[email protected]6dbdc9: defining beans [dataSource,sessionFactory,dvdDAO,userDetailDAO,hibernatetransactionManager,DvdAction,LoginAction,AccountCreationAction]; root of factory hierarchy
.........//hibernate mapping some log file info
2012-12-14 10:22:22,825 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.debug:57 - Loaded [BUILDER] {PackageConfig Name:convention-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
2012-12-14 10:22:22,825 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.debug:57 - Loaded [BUILDER] {PackageConfig Name:hibernate-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
2012-12-14 10:22:22,826 DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor.debug:57 - new I18nInterceptor()
2012-12-14 10:22:22,843 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.debug:57 - Loaded [BUILDER] {PackageConfig Name:hibernateManager namespace:/hibernateManager parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
2012-12-14 10:22:22,850 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.debug:57 - Loaded /hibernateManager/* in 'hibernateManager' package:{ActionConfig * (.{1}()) - action - jar:file:/home/saranya/Desktop/apache-tomcat-6.0.20/webapps/dvd_struts/WEB-INF/lib/struts2-fullhibernatecore-plugin-1.4-GA.jar!/struts-plugin.xml:74:36}
2012-12-14 10:22:22,850 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.debug:57 - Loaded [BUILDER] {PackageConfig Name:basicstruts2 namespace:/ parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
Dec 14, 2012 10:22:22 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Dec 14, 2012 10:22:22 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/dvd_struts] startup failed due to previous errors
2012-12-14 10:22:22,885 INFO org.springframework.web.context.support.XmlWebApplicationContext.doClose:1002 - Closing Root WebApplicationContext: startup date [Fri Dec 14 10:22:09 IST 2012]; root of context hierarchy
2012-12-14 10:22:22,886 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons:422 - Destroying singletons in org.s[email protected]6dbdc9: defining beans [dataSource,sessionFactory,dvdDAO,userDetailDAO,hibernatetransactionManager,DvdAction,LoginAction,AccountCreationAction]; root of factory hierarchy
2012-12-14 10:22:22,887 INFO org.springframework.orm.hibernate3.LocalSessionFactoryBean.destroy:246 - Closing Hibernate SessionFactory
2012-12-14 10:22:22,887 INFO org.hibernate.impl.SessionFactoryImpl.close:805 - closing
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Struts 2 Dvd Application</display-name>
<filter>
<filter-name>Spring_struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<load-on-startup>1</load-on-startup>
</filter>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/dvdstruts-context.xml,/WEB-INF/classes/struts.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter-mapping>
<filter-name>Spring_struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
</web-app>
您可以張貼錯誤的整個堆棧跟蹤? – abalogh
「關閉根WebApplicationContext的」 - 該位意味着你可能不會找到任何豆。但是,它也像你的整個Web應用程序沒有啓動,所以我不能想象你能連打您的應用程序,但如果是這樣的話,我會想你的問題將是「爲什麼不是我的Struts應用程序開始?」這個日誌片段和你陳述的問題之間似乎有些東西。 – chad
顯示完整的stacktrace和你的'web.xml'文件。 –