Announcement Announcement Module
Collapse
No announcement yet.
Junit 4, eclipse, UnsupportedClassVersionError Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.

    Code:
    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(ShadowingClassLoader.java:151)
    	at org.springframework.instrument.classloading.ShadowingClassLoader.loadClass(ShadowingClassLoader.java:102)
    	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    	at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:646)
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:350)
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:227)
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:273)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
    	... 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.

    Comment


    • #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

      Comment

      Working...
      X