Announcement Announcement Module
No announcement yet.
Junit 4, eclipse, UnsupportedClassVersionError Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Junit 4, eclipse, UnsupportedClassVersionError

    I am getting UnsupportedClassVersionError when i run Junit test from eclipse. The test works fine from command line. My test extends from AbstractJpaTests. Ran out of ideas so thought to throw it out to the group.

    Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(Unknown Source)
    	at java.lang.ClassLoader.defineClass(Unknown Source)
    	at org.springframework.instrument.classloading.ShadowingClassLoader.doLoadClass(
    	at org.springframework.instrument.classloading.ShadowingClassLoader.loadClass(
    	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    	at org.hibernate.ejb.Ejb3Configuration.scanForClasses(
    	at org.hibernate.ejb.Ejb3Configuration.configure(
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(
    	... 81 more

  • #2
    What java version is Eclipse running?

    My guess is that your project is compiled using one version of java but your Eclipse junit tests are using different and possibly older jre. Check your project properties and the jre that the tests are using. Command line probably works as your machines JAVA_HOME is the same jre as your project.


    • #3
      Running 1.5

      I am running jdk 1.5 in eclipse. Command line happens to be 1.6.

      Just to try, i configured one of junits to run with 1.6 jre and that DID work. Score!

      Thanks zebthecat