Struts1.2+Spring2.0+Hibernate3.1项目框架构建中的问题及解决方法集锦(1)
前天自己尝试着使用 Eclipse3.2+Myeclipse5.5 搭建一个自己的 Struts1.2+Spring2.0+Hibernate3.1 项目框架,这自己不做还不知道,一做就吓了一跳,怎搭个项目框架就这么难,经过整整一天的摸索这才成功的构建了自己想要的项目框架。现在把项目的主要配置文件清单共享如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="java.sun/xml/ns/j2ee" xmlns:xsi="/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="java.sun/xml/ns/j2ee java.sun/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
怎么看项目是什么框架<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/l</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout></session-config>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
<welcome-file>/modules/login.jsp</welcome-file>
</welcome-file-list>
</web-app>
Struts配置 l
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="loginForm"
type="st.struts.form.LoginForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action attribute="loginForm" input="/modules/login.jsp"
name="loginForm" path="/modules/login" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy"> (1)loginAction交给Sping 代理
<forward name="msg" path="/modules/msg.jsp"></forward>
<forward name="index" path="/index.jsp"></forward>
<forward name="login" path="/modules/login.jsp"></forward>
</action>
</action-mappings>
<message-resources
parameter="st.struts.ApplicationResources" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/l" />
</plug-in>
</struts-config>
Spring整合HIbernate l
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "www.springfra
<beans>
<bean id="dataSource"
class="org.apachemons.dbcp.BasicDataSource"> (2)Spring整合Hibernate 配置 DataSource
<property name="driverClassName">
<value&sql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/morecans</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>1</value>
</property>
</bean>
<bean id="sessionFactory" (3)Spring整合Hibernate 配置 SessionFactory
class="hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/morecans/test/pojo/l</value>
</list>
</property>
</bean>
<bean id="CustomerDAO" class="st.pojo.CustomerDAO">
<property name="sessionFactory"> (4)Spring整合Hibernate 配置 DAO
<ref bean="sessionFactory" />
</property>
</bean>
<import resource="l" />
</beans>
Spring整合Stuts l
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "/dtd/spring-beans.dtd">
<beans>
<bean name="/modules/login" (5)Struts的Action交给Sping 在这里处理。配置LoginAction
class="st.struts.action.LoginAction">
<property name="customerdao">
<ref bean="CustomerDAO" />
</property>
</bean>
</beans>
其他的编码和jsp页面就由大家自己补充了,赫赫。。。。。。。
现在把遇到的问题及解决方法跟大家共享,同时欢迎大家指正和给出就意见和建议。遇到的四个问题:
严重: action: null
java.lang.ClassNotFoundException: org.springframework.web.struts.ContextLoaderPlugIn(一)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:846)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.StandardWrapper.load(StandardWrapper.java:981)
at org.StandardContext.loadOnStart
up(StandardContext.java:4044)
at org.StandardContext.start(StandardContext.java:4350)
at org.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.ContainerBase.addChild(ContainerBase.java:741)
at org.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.ContainerBase.start(ContainerBase.java:1023)
at org.StandardHost.start(StandardHost.java:719)
at org.ContainerBase.start(ContainerBase.java:1015)
at org.StandardEngine.start(StandardEngine.java:443)
at org.StandardService.start(StandardService.java:448)
at org.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at flect.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)
2007-7-12 10:08:03 org.ApplicationContext log
信息: Marking servlet action as unavailable
2007-7-12 10:08:03 org.StandardContext loadOnStartup
严重: Servlet /ssh2 threw load() exception
javax.servlet.UnavailableException(二)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:880)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.StandardWrapper.load(StandardWrapper.java:981)
at org.StandardContext.loadOnStartup(StandardContext.java:4044)
at org.StandardContext.start(StandardContext.java:4350)
at org.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.ContainerBase.addChild(ContainerBase.java:741)
at org.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConf
ig.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.ContainerBase.start(ContainerBase.java:1023)
at org.StandardHost.start(StandardHost.java:719)
at org.ContainerBase.start(ContainerBase.java:1015)
at org.StandardEngine.start(StandardEngine.java:443)
at org.StandardService.start(StandardService.java:448)
at org.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at flect.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)
解决方法:加入spring2.0.6的最核心得包:
spring.jar
spring-aspects.jar
spring-mock.jar
重新编译(或者Project --〉clean)。。。。。。。。
严重: Servlet /ssh2 threw load() exception
javax.servlet.UnavailableException: org.springframework.isterScope(三)(Ljava/lang/String;Lorg/springframework/beans/factory/config/Scope;)V
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.StandardWrapper.load(StandardWrapper.java:981)
at org.StandardContext.loadOnStartup(StandardContext.java:4044)
at org.StandardContext.start(StandardContext.java:4350)
at org.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.ContainerBase.addChild(ContainerBase.java:741)
at org.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.ContainerBase.start(ContainerBase.java:1023)
at org.
e.StandardHost.start(StandardHost.java:719)
at org.ContainerBase.start(ContainerBase.java:1015)
at org.StandardEngine.start(StandardEngine.java:443)
at org.StandardService.start(StandardService.java:448)
at org.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at flect.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)
解决方法:加入spring2.0.6的核心得包:
spring-beans.jar
重新编译(或者Project --〉clean)。。。。。。。。
严重: Servlet /ssh2 threw load() exception
javax.servlet.UnavailableException: ateConcurrentMapIfPossible(I)Ljava/util/Map(四)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.StandardWrapper.load(StandardWrapper.java:981)
at org.StandardContext.loadOnStartup(StandardContext.java:4044)
at org.StandardContext.start(StandardContext.java:4350)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.ContainerBase.backgroundProcess(ContainerBase.java:1307)
at org.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1571)
at org.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1580)
at org.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1560)
at java.lang.Thread.run(Thread.java:619)
解决方法:加入spring2.0.6的核心得包:
spring-core.jar
重新编译(或者Project --〉clean)。。。。。。。。
严重: Servlet /ssh2 threw load() exception
javax.servlet.UnavailableException: org/springframework/beans/factory/support/ConfigurableBeanFactoryUtils(五)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.StandardWrapper.l
oad(StandardWrapper.java:981)
at org.StandardContext.loadOnStartup(StandardContext.java:4044)
at org.StandardContext.start(StandardContext.java:4350)
at org.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.ContainerBase.addChild(ContainerBase.java:741)
at org.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.ContainerBase.start(ContainerBase.java:1023)
at org.StandardHost.start(StandardHost.java:719)
at org.ContainerBase.start(ContainerBase.java:1015)
at org.StandardEngine.start(StandardEngine.java:443)
at org.StandardService.start(StandardService.java:448)
at org.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at flect.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)
解决方法:加入spring2.0.6的核心得包:
spring-hibernate3.jar
spring-dao.jar
spring-ibatis.jar
spring-aop.jar
spring-context.jar
重新编译(或者Project --〉clean)。。。。。。。。
2007-7-12 11:53:12 org.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:/Program Files/Java/jdk1.6.0_01/bin;E:/Program Files/Apache Software Foundation/Tomcat 6.0/bin
2007-7-12 11:53:12 http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2007-7-12 11:53:12 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 625 ms
2007-7-12 11:53:12 org.StandardService start
信息: Starting service Catalina
2007-7-12 11:53:12 org.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.10
log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
log4j:WARN Please initialize the log4j system properly.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论