struts2+spring2+hibernate3整合 出错 急!!!

Nicky_HelloWorld 2009-09-15 01:55:49
信息: ... initialized Struts-Spring integration successfully
2009-9-15 13:46:11 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts
Action class [bookAction] not found - action - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/SSH2/WEB-INF/classes/struts.xml:11:65
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:374)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:329)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:429)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-9-15 13:46:11 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2009-9-15 13:46:11 org.apache.catalina.core.StandardContext start
严重: Context [/SSH2] startup failed due to previous errors
2009-9-15 13:46:11 org.apache.catalina.core.ApplicationContext log
...全文
244 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
Epiphone 2009-10-10
  • 打赏
  • 举报
回复
:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/SSH2/WEB-INF/classes/struts.xml

应该是没找到struts.xml 你把tomcat安装的时候 不要选择有空格的目录 比如直接安装倒D:/Service/tomcat6 这样就可以了
Nicky_HelloWorld 2009-09-16
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 yingkeda 的回复:]
你配置都有问题:
1:是你的struts.xml的action=bookAction  必须跟你spring的bean绑定!
2:如果你用的是struts2.1.6以上 你先把 <constant name="struts.devMode" value="false" />  因为里面有个bug!

我先说这两点!你不一下子把代码贴上,让我看都不容易!呵呵
[/Quote]
呵呵。。第一次在CSDN上发贴啊,现在把一些配置文件发出来:

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="bookDAO" class="com.test.dao.BookDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>

applicationContext-db.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
<property name="url"
value="jdbc:microsoft:sqlserver://localhost;databaseName=libSystem" />
<property name="username" value="sa" />
<property name="password" value="sa" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.DerbyDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/test/domain/Book.hbm.xml</value>
</list>
</property>
</bean>
</beans>

applicationContext-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="bookManageServiceTarget" class="com.test.serviceImpl.BookManageServiceImpl">
<property name="bookDAO">
<ref bean="bookDAO" />
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="bookManageService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref bean="bookManageServiceTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly
</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<bean id="bookAction" scope="prototype" class="com.test.action.BookAction">
<property name="bookManageService">
<ref bean="bookManageService" />
</property>
</bean>

</beans>

struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.objectFactory" value="spring"/>

<package name="book" extends="struts-default">
<action name="list" method="execute" class="bookAction">
<result>list.jsp</result>
<result name="input">list.jsp</result>
</action>
<action name="remove" method="remove" class="bookAction">
<result>list.jsp</result>
<result name="input">list.jsp</result>
</action>
<action name="save" method="save" class="bookAction">
<result>list.jsp</result>
<result name="input">list.jsp</result>
</action>
</package>
</struts>

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-*.xml</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

</web-app>

希望加你QQ交谈。。呵呵
accps1 2009-09-16
  • 打赏
  • 举报
回复
sysout.print("关注中。。。");
yinzisheng 2009-09-16
  • 打赏
  • 举报
回复
bookAction 没有配置。。
岁月之梦 2009-09-16
  • 打赏
  • 举报
回复
action没有被发现,你加spring.jar没有?
岁月之梦 2009-09-16
  • 打赏
  • 举报
回复
你配置都有问题:
1:是你的struts.xml的action=bookAction 必须跟你spring的bean绑定!
2:如果你用的是struts2.1.6以上 你先把<constant name="struts.devMode" value="false" /> 因为里面有个bug!

我先说这两点!你不一下子把代码贴上,让我看都不容易!呵呵
lixiao1387 2009-09-16
  • 打赏
  • 举报
回复
Action class [bookAction] not found - action - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/SSH2/WEB-INF/classes/struts.xml:11:65
qiaozirue 2009-09-16
  • 打赏
  • 举报
回复
你的struts.xml 11行有错误..自已仔细检查一下吧..呵呵.
Nicky_HelloWorld 2009-09-16
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 jumpheightway 的回复:]
你的struts.xml配置就是错的
[/Quote]

不会吧,这是struts2里面的配置,刚学struts2,但struts.xml这里应该没有错的,而且那个bookAction我在applicationContext-service.xml里配置了。。
zyw358486 2009-09-16
  • 打赏
  • 举报
回复
你自己看下这篇文章,http://hi.baidu.com/javashmily/blog/item/c28c4c61d67b9943ebf8f89d.html
应该能找到答案
archko 2009-09-16
  • 打赏
  • 举报
回复
<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring"
class="org.apache.struts2.spring.StrutsSpringObjectFactory" />
加了这个,有可能还是错,为什么呢?
如果使用IDEA请注意把配置文件选上,就是在facets里,少一个它不运行.就像WEB.XML错一个都不行.
如果是MYECLIPSE,这个好像也是无法识别配置文件导致的,
为什么无法识别呢.我不知道原因.就是不知道在哪里改.
-----------------------------------------
建议,删除项目,然后重建一个,如果是MYECLIPSE的话,就添加它里面的JAR肯定没错.不爽,你再删除,加你自己的.
还有就是猫,报错能力有点那个.如果机器不错,可以换GLASSFISH,或是JETTY稍微详细点.比如有没有少JAR就知道了.
zyw358486 2009-09-16
  • 打赏
  • 举报
回复
<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring"
class="org.apache.struts2.spring.StrutsSpringObjectFactory" />

这个bean要放在package的外面
zyw358486 2009-09-16
  • 打赏
  • 举报
回复
问下,你的访问路径是bookAction.action,还是save.action remove.action list.action.如果是第一个就错了.
Leiffort 2009-09-15
  • 打赏
  • 举报
回复
貌似struts.xml的配置文件没有加载到tomcat的目录下吧!自己在tomcat的目录下看看、、、
在就是看web.xml中 spring是否配好了、、
jumpheightway 2009-09-15
  • 打赏
  • 举报
回复
你的struts.xml配置就是错的
Nicky_HelloWorld 2009-09-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 liguangwen86 的回复:]
Action class [bookAction] not found - action - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/SSH2/WEB-INF/classes/struts.xml:11:65

错误在这里,好好看看
[/Quote]
我确定大小写没有错啊。。。郁闷
难道struts 2 里面有什么东西我没有注意 到??
弄了一下午,还没有搞出来,抓狂!!!

可以提供些思路给我吗????
feiling111222 2009-09-15
  • 打赏
  • 举报
回复
bookAction应该没有配置好
看看路径是否正确,大小写有没有写错等
qyhdt 2009-09-15
  • 打赏
  • 举报
回复
struts.xml配置里面bookAction没有配置好 你看看是不是大小写错了 或者是你的单词写错了
Nicky_HelloWorld 2009-09-15
  • 打赏
  • 举报
回复
我应试在applicationContext-service.xml中配置了
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="bookManageServiceTarget" class="com.test.serviceImpl.BookManageServiceImpl">
<property name="bookDAO">
<ref bean="bookDAO" />
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="bookManageService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref bean="bookManageServiceTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly
</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<bean id="bookAction" scope="prototype" class="com.test.action.BookAction">
<property name="bookManageService">
<ref bean="bookManageService" />
</property>
</bean>

</beans>
fengsimon2008 2009-09-15
  • 打赏
  • 举报
回复
没有配置好BookAction
加载更多回复(3)

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧