卡两天了 包里也有org.hibernate.dialect.PostgreSQLDialect这个类 但是就是找不到
异常:Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.PostgreSQLDialect;]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
... 57 more
Caused by: java.lang.ClassNotFoundException: org/hibernate/dialect/PostgreSQLDialect;
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
... 58 more
2013-1-22 9:01:08 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
2013-1-22 9:01:08 org.apache.catalina.core.StandardContext startInternal
严重: Context [/s_test1] startup failed due to previous errors
2013-1-22 9:01:08 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2013-1-22 9:01:08 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/s_test1] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-1-22 9:01:08 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
2013-1-22 9:01:08 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
2013-1-22 9:01:08 org.apache.catalina.startup.Catalina start
信息: Server startup in 9653 ms
下面是applicationcontext.xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:aop="http://www.springframework.org/schema/aop"     xmlns:tx="http://www.springframework.org/schema/tx"     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.5.xsd    http://www.springframework.org/schema/context    http://www.springframework.org/schema/context/spring-context-2.5.xsd    http://www.springframework.org/schema/aop    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd    http://www.springframework.org/schema/tx    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> 
<!-- struts配置文件中取得loginaction spring把业务层leeservice注入action中-->
     <bean id="LoginAction" class="esw.test.LoginAction"  scope="prototype">
        <property name="leeService" ref="leeService"/> 
    </bean>    <!-- 业务逻辑组件   spring把DAO层persondao注入业务层中-->
    <bean id="leeService" class= "esw.test.LeeServiceImpl">
    <property name="personDao" ref="personDao"></property>
    </bean>
       
<!--  Daobean    spring把sessionfactory注入dao层-->
    <bean id="personDao" class="esw.test.PersonDaoHibernate">
    
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
<!--     声明bean -->    
    
    
    
  
    <!-- 数据源 tomcat连接池 -->
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" >
      <property name="jndiName" value="java:comp/env/postgre"/>
    </bean>
      
    <!-- sessionfactory代码 -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
   
      <property name="dataSource" ref="dataSource"></property>
    
      <property name="mappingResources">
              <list> 
                <value>Person.hbm.xml</value> 
              </list> 
      </property>
      
      
<!-- 这种写法为什么有错误?为什么显示红叉? 提示说:cvc-complex-type.2.3: Element 'property' cannot have character [children], because the  type's content type is element-only.
   
      <property name="dialect"> org.hibernate.dialect.PostgreSQLDialect</property>
      <property name="show_sql">true</property>
      <property name="hbm2dd1.auto">update</property>
      <property name="fomat">true</property>
-->
      
      
      
      <property name="hibernateProperties">             <value>                hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect;                hibernate.show_sql=true ;
                
                hibernate.hbm2dd1.auto=update;
                
                hibernate.format_sql=true;            </value> 
       </property> 
    </bean>
</beans>
ssh框架hibernate.dialectbean

解决方案 »

  1.   

    不知道你用的是不是maven,有的jar包存在,但不一定是需求的那个版本。
      

  2.   

    我用的都是最新版本hibernate4.2 struts2.3.8 spring3.2 应该是哪个问题?包的冲突?
      

  3.   

    可以说包的冲突吧。就比如说两个jar包下都有某个类,有可能导入的时候就导入了错误的类。。
    当然,这只是我的猜测。。
    不是很确定。
      

  4.   

    2013-1-22 10:38:56 org.apache.catalina.core.AprLifecycleListener init
    信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
    2013-1-22 10:38:56 org.apache.tomcat.util.digester.SetPropertiesRule begin
    警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Copy of s_test1' did not find a matching property.
    2013-1-22 10:38:57 org.apache.coyote.AbstractProtocol init
    信息: Initializing ProtocolHandler ["http-bio-8080"]
    2013-1-22 10:38:57 org.apache.coyote.AbstractProtocol init
    信息: Initializing ProtocolHandler ["ajp-bio-8009"]
    2013-1-22 10:38:57 org.apache.catalina.startup.Catalina load
    信息: Initialization processed in 1346 ms
    2013-1-22 10:38:57 org.apache.catalina.core.StandardService startInternal
    信息: Starting service Catalina
    2013-1-22 10:38:57 org.apache.catalina.core.StandardEngine startInternal
    信息: Starting Servlet Engine: Apache Tomcat/7.0.34
    2013-1-22 10:39:01 org.apache.catalina.core.ApplicationContext log
    信息: No Spring WebApplicationInitializer types detected on classpath
    2013-1-22 10:39:01 org.apache.catalina.core.ApplicationContext log
    信息: Initializing Spring root WebApplicationContext
    2013-1-22 10:39:01 org.springframework.web.context.ContextLoader initWebApplicationContext
    信息: Root WebApplicationContext: initialization started
    2013-1-22 10:39:02 org.springframework.context.support.AbstractApplicationContext prepareRefresh
    信息: Refreshing Root WebApplicationContext: startup date [Tue Jan 22 10:39:02 CST 2013]; root of context hierarchy
    2013-1-22 10:39:02 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    2013-1-22 10:39:02 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7c41f227: defining beans [LoginAction,leeService,personDao,dataSource,sessionFactory]; root of factory hierarchy
    2013-1-22 10:39:03 org.hibernate.annotations.common.Version <clinit>
    INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
    2013-1-22 10:39:03 org.hibernate.Version logVersion
    INFO: HHH000412: Hibernate Core {4.1.9.Final}
    2013-1-22 10:39:03 org.hibernate.cfg.Environment <clinit>
    INFO: HHH000206: hibernate.properties not found
    2013-1-22 10:39:03 org.hibernate.cfg.Environment buildBytecodeProvider
    INFO: HHH000021: Bytecode provider name : javassist
    2013-1-22 10:39:03 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
    WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    2013-1-22 10:39:05 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
    信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7c41f227: defining beans [LoginAction,leeService,personDao,dataSource,sessionFactory]; root of factory hierarchy
    2013-1-22 10:39:05 org.springframework.web.context.ContextLoader initWebApplicationContext
    严重: Context initialization failed
    这时控制台最上面的报错提示
      

  5.   

    网上说是 spring.aop的3个asm包和hibernate的包冲突 需要删除 我44
     谢谢