Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported Class Version Error

While trying to call an EJB made using NETbeans (using jdk1.7) from a client made using Eclipse IDE (using jdk1.6), I am getting following error-

Exception in thread "main" java.lang.UnsupportedClassVersionError: stateless/TestEjbRemote : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:688)
    at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:463)
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:414)
    at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at Main.main(Main.java:19)

Any solution to this problem ?

like image 601
Rohit Elayathu Avatar asked Feb 01 '12 06:02

Rohit Elayathu


2 Answers

Try to change the Target JRE version to 1.6 in Build Configuration.

like image 67
Ravindra Gullapalli Avatar answered Sep 19 '22 01:09

Ravindra Gullapalli


Problem was- I was calling EJB,made using jdk1.7 from client, which was using jdk1.6. Switched the jdk1.7 to jdk 1.6, it worked. or one can switch jdk1.6 to 1.7, then also it would work. Conclusion- u can call any EJB which is using either the same version or lower version of jdk as the caller.

like image 39
Rohit Elayathu Avatar answered Sep 20 '22 01:09

Rohit Elayathu