Struts1.2+Spring2.0+Hibernate3.1项目框架构建中的问题及解决方法集锦

    前天自己尝试着使用 Eclipse3.2+Myeclipse5.5 搭建一个自己的 Struts1.2+Spring2.0+Hibernate3.1 项目框架,这自己不做还不知道,一做就吓了一跳,怎搭个项目框架就这么难,经过整整一天的摸索这才成功的构建了自己想要的项目框架。现在把项目的主要配置文件清单共享如下:

web.xml   项目配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/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>/WEB-INF/struts-config.xml</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配置   struts-config.xml 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
 <data-sources />
 <form-beans>
  <form-bean name="loginForm"
   type="com.morecans.test.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="com.morecans.test.struts.ApplicationResources" />
 <plug-in
  className="org.springframework.web.struts.ContextLoaderPlugIn">
  <set-property property="contextConfigLocation"
   value="/WEB-INF/classes/applicationContext.xml" />
 </plug-in>
</struts-config> 

Spring整合HIbernate    applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "
http://www.springframework.org/dtd/spring-beans.dtd
">

<beans>
 <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource"> (2)Spring整合Hibernate   配置 DataSource
<property name="driverClassName">
   <value>com.mysql.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="org.springframework.orm.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/Customer.hbm.xml</value>
   </list>
  </property>
 </bean>

 <bean id="CustomerDAO" class="com.morecans.test.pojo.CustomerDAO">
  <property name="sessionFactory">    (4)Spring整合Hibernate   配置 DAO
   <ref bean="sessionFactory" />
  </property>
 </bean>
 <import resource="applicationContext-zxy.xml" />
</beans>

Spring整合Stuts   applicationContext-zxy.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "
http://www.springframework.org/dtd/spring-beans.dtd
">

<beans>
 <bean name="/modules/login"                       (5)Struts的Action交给Sping 在这里处理。配置LoginAction
  class="com.morecans.test.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.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
 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: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.apache.catalina.core.ApplicationContext log
信息: Marking servlet action as unavailable
2007-7-12 10:08:03 org.apache.catalina.core.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.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
 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: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.beans.factory.config.ConfigurableListableBeanFactory.registerScope(三)(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.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
 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: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: org.springframework.core.CollectionFactory.createConcurrentMapIfPossible(I)Ljava/util/Map(四)
 at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
 at org.apache.catalina.core.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.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1307)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1571)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1580)
 at org.apache.catalina.core.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.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
 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: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.apache.catalina.core.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 org.apache.coyote.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.apache.catalina.core.StandardService start
信息: Starting service Catalina
2007-7-12 11:53:12 org.apache.catalina.core.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.
2007-7-12 11:53:16 org.apache.catalina.core.ApplicationContext log
信息: Initializing WebApplicationContext for Struts ActionServlet 'action', module ''
2007-7-12 11:53:21 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2007-7-12 11:53:21 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2007-7-12 11:53:21 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/172  config=null
2007-7-12 11:53:21 org.apache.catalina.startup.Catalina start
信息: Server startup in 9391 ms

在项目构建是使用MySQL作数据库的过程又出现了两个Bug:

严重: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: No getter method for property userid of bean org.apache.struts.taglib.html.BEAN
 at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:973)
 at org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:121)
 at org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
 at org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:81)
 at org.apache.jsp.modules.login_jsp._jspx_meth_html_005ftext_005f0(login_jsp.java:228)
 at org.apache.jsp.modules.login_jsp._jspx_meth_html_005fform_005f0(login_jsp.java:169)
 at org.apache.jsp.modules.login_jsp._jspx_meth_html_005fhtml_005f0(login_jsp.java:130)
 at org.apache.jsp.modules.login_jsp._jspService(login_jsp.java:83)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
 at com.morecans.test.LoginFilter.doFilter(LoginFilter.java:34)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
 at java.lang.Thread.run(Thread.java:619)
2007-7-15 15:05:10 org.apache.catalina.core.StandardWrapperValve invoke


分析:
        
No getter method for property userid of bean org.apache.struts.taglib.html.BEAN表明在modules.login.jsp中的表单设计中存在userid属性在对应的actionform bean中找不到对应的属性或者setter/getter方法

解决方法: 
         在actionform bean中加入相应的属性及setter/getter方法。

严重: Servlet.service() for servlet action threw exception
java.sql.SQLException: Table 'morecans.morecans__customer' doesn't exist
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
 at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
 at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:933)
 at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
 at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
 at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
 at org.hibernate.loader.Loader.doQuery(Loader.java:391)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
 at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
 at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
 at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
 at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
 at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
 at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
 at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
 at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
 at org.springframework.orm.hibernate3.HibernateTemplate$2.doInHibernate(HibernateTemplate.java:489)
 at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
 at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:483)
 at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:477)
 at com.morecans.test.pojo.CustomerDAO.findById(CustomerDAO.java:53)
 at com.morecans.test.struts.action.LoginAction.execute(LoginAction.java:74)
 at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.morecans.test.EncodingFilter.doFilter(EncodingFilter.java:27)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.morecans.test.LoginFilter.doFilter(LoginFilter.java:32)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
 at java.lang.Thread.run(Thread.java:619)


分析:
          Table 'morecans.morecans__customer' doesn't exist 表明hibernate找不到customer表,这里主要是由于连接mysql时必须提供了数据库名morecans造成找不到数据表。

解决方法:  
          去掉customer.hbm.xml中<class name="com.morecans.test.pojo.Customer" table="customer" catalog="morecans">的catalog="morecans,就可以解决此问题。

KO。。。!终于可以结束了!ye!

摘录来源:http://blog.csdn.net/Morecans/archive/2007/07/12/1686416.aspx —— Morecans的专栏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值