Unsupported Class Version Error - ejb

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 ?

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

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.

I had the same problem but I was using textpad though. The solution was pretty simple. Try placing the class in conflict on a different location (a backup folder perhaps whatever) or you can just simply delete it as long as it doesn't exist on the same directory. Then try compiling the java file so you can have a new class built to your computer's specification. Try if it works for you coz it worked for me. :)

It's the second time I've had the issue, just change the build configuration of this project.
Right click your project name --> [properties] --> [java compiler] --> [Enable project specific settings] --> set [compiler compliance level] to 1.7
Eclipse has it's own compiler, no matter which version of javac(jdk) in you system,so you must configure the version of eclipse compiler firstly.
Reference: java.lang.UnsupportedClassVersionError: Bad version number in .class file?

Related

Is V3 Identity Authentication compatible with JDK 1.6? If yes, which and how should I make use of it?

I am just wondering if the OSFactory.builderV3() method can run on JDK 1.6.
It returns the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openstack4j/openstack/OSFactory : Unsupported major.minor version 52.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 Test.main(Test.java:9)
I do know there is a Jersy2JDK1.6 connector works on Keystone V2, like:
org.pacesys
openstack4j-core
3.0.0
org.pacesys.openstack4j.connectors
openstack4j-jersey2-jdk1.6
3.0.0
but in terms of my project, it requires V3 Authentication.
The problem is actually a Java problem. You are trying to run code that was built for JDK 1.8 or later on a JDK 1.6 platform. That won't work. The JDK 1.6 JVM does not understand that version of the bytecode.
In theory, you could try downloading the sourcecode for the library and its dependencies, and building them with a JDK 1.6 compiler / tool-chain. HOWEVER, that will only work if the library and its dependencies are fully Java 6 compatible; i.e. both in terms of source code syntax AND use of the standard Java SE APIs.
In this case, I think it is highly unlikely that that will work. According to the README.md file in the OpenStack4j Github repo:
Requirements
OpenStack4j 3.0.X - Java 7 (JDK 8 preferred)
OpenStack4j 2.0.X - Java 7
The best solution is to upgrade to Java 8. Java 6 was EOL'ed in April 2013.
There is a saying:
"The most important thing to do if you are in a hole is to stop digging."
A dev't project that is stuck on Java 6 is in a hole.

IKVM with UnsupportedClassVersionError

I get the following error when trying to run my simple java class with ikvm on Windows.
Exception in thread "main" java.lang.UnsupportedClassVersionError: dummy (52
.0)
at IKVM.NativeCode.java.lang.ClassLoader.defineClass1(Unknown Source)
...
at IKVM.NativeCode.java.lang.Class.forName0(Unknown Source)
at java.lang.Class.forName(Class.java:361)
Since I am able to run the same class on my Mac with mono - it shouldn't be a the JDK version (which is 1.8). I have checked the classpath, which directs to the /lib directory of ikvm and the current directory.
Both ikvm and ikvmc won't work on Windows Server 2012. Everything is accessible - javac, csc, ikvmc. I get the classpath just fine with echo %CLASSPATH%.
I am missing something here - but what? I have been searching and reading through the mailing list; it's apparently the most asked question to be mentioned in the FAQ, but I don't see the next steps of troubleshooting this.
Thank you for your help!

RAD 8.5 unable to run standalone java app that calls EJB and MQ

I used to be able to run my standalone java app that calls EJB and MQ using JNDI on RAD 7.5.5. I upgraded to RAD 8.5 and when I tried to run it, I received the error Failed to create InitialContext using factory specified in hashtable. I'm also using the same WAS 7.0.0.9 for both RAD version so I'm not sure why it's not working now.
Is there anything special that I need to do in RAD 8.5?
This is my bootstrap classpath entries: WAS v7.0 JRE, %WAS_RUNTIME%\com.ibm.ws.ejb.thinclient_7.0.0.jar, WAS v7.0 lib.
Below are the lines where I set up the environment (the second line seems to be needed for RAD 8.5):
System.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");
System.setProperty("com.ibm.ws.naming.wsn.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
Below is the stack trace from my code:
2012-11-30 16:50:14,945 main FATAL ram.hs.edi.EDIDaemon(line 183) - Unable to get running status: javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable. Root exception is java.lang.NullPointerException
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
at javax.naming.InitialContext.internalInit(InitialContext.java:295)
at javax.naming.InitialContext.<init>(InitialContext.java:212)
at ram.hs.edi.utils.MQReader.open(MQReader.java:85)
at ram.hs.edi.EDIDaemon.isRunning(EDIDaemon.java:406)
at ram.hs.edi.EDIDaemon.run(EDIDaemon.java:168)
at ram.hs.edi.EDIDaemon.main(EDIDaemon.java:898)
Caused by: java.lang.NullPointerException
at com.ibm.ws.naming.util.CommonHelpers$2.run(CommonHelpers.java:268)
at com.ibm.ws.naming.util.CommonHelpers$2.run(CommonHelpers.java:264)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
at com.ibm.ws.naming.util.CommonHelpers.mergeJndiProviderProperties(CommonHelpers.java:263)
at com.ibm.ws.naming.util.CommonHelpers.mergeWsnJndiProperties(CommonHelpers.java:159)
at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:186)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
... 8 more
Thanks
This may be little late answering it but please try to do the following:
1) Add the jar "com.ibm.ws.orb_7.0.0.jar" or equivalent jar on the Bootstrap path of your standalone Java Class.
2) Add the jar "com.ibm.ws.webservices.thinclient_7.0.0" or equivalent jar on the JVM Class path.
After doing the above I was able to get the InitalContext successfully. Hope this helps.

Having trouble running a custom jar on Amazon AWS

I'm having trouble running a custom jar on Elastic Map-Reduce
I'm using jdk1.6.0_26, Hadoop 0.20.205, and compiling with Eclipse on my computer and everything works perfectly fine
for example if I ran the following on my computer it would be successful
hadoop jar MaxTemperature.jar input/temperature.txt output
I specified the jar as the following on AWS
s3n://chrishadoop/MaxTemperature.jar
and I specified the arguments as
s3n://chrishadoop/input/temperature.txt s3n://chrishadoop/output
I did not specify the main class because I pointed to it in the manifest
Here is the jar I'm using, I will make it public for a little while
https://s3.amazonaws.com/chrishadoop/MaxTemperature.jar
Here is the error I'm getting
2012-07-08 19:31:39,824 INFO com.amazonaws.elasticmapreduce.statepusher.StatePusher (main): Pusher awoke, starting to push data into simpledb...
2012-07-08 19:31:40,552 FATAL com.amazonaws.elasticmapreduce.statepusher.StatePusher (main): Fatal Exception raised while extracting data from hadoop and pushing to simpledb
java.lang.NoClassDefFoundError: org/codehaus/jackson/map/JsonMappingException
at com.amazonaws.elasticmapreduce.statepusher.StatePusher.run(StatePusher.java:65)
at com.amazonaws.elasticmapreduce.statepusher.StatePusher.main(StatePusher.java:205)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
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)
... 2 more
There is a version of Jackson which is installed as part of the AMI, and I'm guessing you're bundling a different version of Jackson? The error seems to be happening in the support code which makes "enable debugging" work.

JRE System Library 1.3.1_20 notify an error on OracleDataSource Usage

Java -version (Sco Openserver 5)
Java(TM) 2 Runtime Environment, Standard Edition (build SCO-UNIX-J2SE-1.3.1_22:*
FCS*:20080305)
Classic VM (build SCO-UNIX-J2SE-1.3.1_22:*FCS*:20080305, green threads, sunwjit)
Problem :
OracleDataSource ods = OracleDatasource();
It occurs error :
The type javax.sql.DataSource cannot be resolved. It is indirectly referenced from required .
class files
How to solve this problem?
You are using a wrong driver. Your driver requires java 1.4.
The javax.sql.DataSource has been added with java 1.4.
http://docs.oracle.com/javase/7/docs/api/javax/sql/DataSource.html
Make sure that you are using a JDBC driver that supports java 1.3.
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-10201-088211.html the classes12.jar should work for you.
This means that your program is missing a library on the class path.
You must make sure that, for example, when you export a compiled jar file, that you export the libraries along with it ...
Of course.... I'm assuming you were able to compile your program correctly.

Resources