applicationContext-compass.xml  有问题啊compassGps   Caused by: java.lang.ClassCastException: $Proxy0 cannot be cast to org.hibernate
.impl.SessionFactoryImpl 

解决方案 »

  1.   


    tomcat要使用 JNDI进行数据库连接需要特殊配置才能!
    建议概要jdbc进行连接
      

  2.   

    no JNDI name configured 
    检查下jndi配置 tomcat下面的conf/server.xml 
    <Resource
              name="jdbc/test"
              type="javax.sql.DataSource"
              password="bb"
              driverClassName="com.mysql.jdbc.Driver"
              maxIdle="2"
              maxWait="50"
              username="root"
              url="jdbc:mysql://localhost:3306/test"
              maxActive="4"/>
      

  3.   

    问题补充:我是这样配置的数据源和sessionFactory,好像没有问题
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
           
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
    value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
    </property>
    <property name="url"
    value="jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=datashare">
    </property>
    <property name="username" value="sa"></property>
    <property name="password" value="123"></property>
    </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.SQLServerDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>               
    </props>
    </property>
    <property name="mappingResources">
    <list>

    <value>com/datashare/model/Book.hbm.xml</value>

    </list>
    </property>
    </bean>
    .......

    </beans>
      

  4.   

    支持3楼 但考虑到移植性 建议使用jdbc 
      

  5.   

    问题已经解决了,是Spring类库的问题,把2.0 换成2.5就可以了