SpringBean未在struts2中配置?

SpringBean未在struts2中配置?,spring,struts2,struts-config,Spring,Struts2,Struts Config,我正在使用struts2、spring和hibernate做一个项目。我在struts.xml文件中遇到了一个问题,它没有使用applictioncontext.xml中声明的bean。 我的applicationcontext.xml如下所示 <bean id="dvdDAO" class="com.ideas2it.dvdstruts.DvdDAO"> <property name="sessionFactory" ref="sessionFactory"/

我正在使用struts2、spring和hibernate做一个项目。我在struts.xml文件中遇到了一个问题,它没有使用applictioncontext.xml中声明的bean。 我的applicationcontext.xml如下所示

    <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"/>
my 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>

Struts 2 Dvd应用程序
弹簧撑杆
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
1.
上下文配置位置
/WEB-INF/config/dvdstruts context.xml,/WEB-INF/classes/struts.xml
org.springframework.web.context.ContextLoaderListener
弹簧撑杆
/*
Login.jsp

尝试将
添加到
applicationContext.xml
,并检查库的版本和编号。

我通过更换jar版本解决了问题。谢谢你的帮助

你能发布整个错误跟踪吗?“关闭根WebApplicationContext”-这意味着你可能找不到任何bean。但是,看起来你的整个网络应用程序都没有启动,所以我无法想象你甚至可以点击你的应用程序,但是如果是这样的话,我想你的问题应该是“为什么我的struts应用程序没有启动?”这个日志片段和你所说的问题之间似乎有点不对劲。显示完整的stacktrace和你的
web.xml
文件。你在使用struts 2 spring插件吗?@abalogh我发布了完整的错误stacktrace。什么的jar版本?我从struts2-spring-plugin-2.2.3改为struts2-spring-plugin-2.1.6。包含所有版本很有帮助询问问题时的信息,包括各个jar版本。你也应该使用依赖关系管理系统,比如Maven或类似的系统。是的,我对这个领域不熟悉。以后我会包括所有的信息。我没有使用Maven。
    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.springframework.beans.factory.support.DefaultListableBeanFactory@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.springframework.beans.factory.support.DefaultListableBeanFactory@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.
<?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>