首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

nested exception is java.lang.UnsupportedClassVersionError: Bad version number i

2014-01-26 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name sessionFacto

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class file
sessionfactory的错误看到了不少的解答,但是都和我的不太一样,

applicationContext.xml内容
<beans>
<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.Oracle9Dialect </prop>
<prop key="hibernate.show_sql">true </prop>
<prop key="hibernate.format_sql">true </prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>xml/login.hbm.xml </value>
<value>xml/Class.hbm.xml </value>
<value>xml/Student.hbm.xml </value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver </value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@127.0.0.1:1521:tianfei </value>
</property>
<property name="username">
<value>scott </value>
</property>
<property name="password">
<value>tiger </value>
</property>
</bean>
</beans>

web.xml内容
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>
<filter>
  <filter-name>filter </filter-name>
  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class>
</filter>
<filter-mapping>
  <filter-name>filter </filter-name>
  <url-pattern>*.do </url-pattern>
</filter-mapping>

<display-name>
springWeb </display-name>
<servlet>
  <servlet-name>spring </servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class>
  <load-on-startup>2 </load-on-startup>
</servlet>
<servlet-mapping> 
  <servlet-name>spring </servlet-name>
  <url-pattern>*.do </url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html </welcome-file>
<welcome-file>index.htm </welcome-file>
<welcome-file>index.jsp </welcome-file>
<welcome-file>default.html </welcome-file>
<welcome-file>default.htm </welcome-file>
<welcome-file>default.jsp </welcome-file>
</welcome-file-list>

</web-app>
用的myeclipse,tomcat一启动就报错

------解决方法--------------------------------------------------------
是不是spring和hibernate的版本不兼容?
------解决方法--------------------------------------------------------
Bad version
提示版本不对啊  可能不兼容吧!
------解决方法--------------------------------------------------------
在applicationContext.xml中,你的dataSource和sessionFactory在同一个文件中,所以

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name="dataSource" >
<ref bean="dataSource"/ >

改成

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >         

热点排行