Wednesday 20 May 2015

OAF: Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

Recently when I was trying to import a page XML into a R12.1.3 instance in a VM using XMLImporter, I got the below error:
 Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file  
     at java.lang.ClassLoader.defineClass2(Native Method)  
     at java.lang.ClassLoader.defineClass(ClassLoader.java:719)  
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160)  
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:254)  
     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)  
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)  
     at java.security.AccessController.doPrivileged(Native Method)  
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)  
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)  
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)  
     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)  
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)  
     at java.lang.Class.forName0(Native Method)  
     at java.lang.Class.forName(Class.java:164)  
     at oracle.adf.mds.tools.util.ConnectUtils.getDBConnection(ConnectUtils.java:165)  
     at oracle.jrad.tools.xml.importer.XMLImporter.importDocuments(XMLImporter.java:228)  
     at oracle.jrad.tools.xml.importer.XMLImporter.main(XMLImporter.java:84)  
Reason:
Wrong java version was referenced, because the I didn't run the environment file.

I was getting the below details when I run "java -version"
 java version "1.5.0_08"  
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)  
 Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)  
Solution:
Source the environment using the .env file, before trying to run the import command. Once the environment file is run, it will set the environment variables. You need to run this before running any utilities.

In some cases, it will be configured to run automatically.

The command I used :
 . /oracle/r12/VIS121/apps/apps_st/appl/APPSVIS121_ebs121-vm.env  
I got the below details when I run "java -version" after sourcing the environment.
 java version "1.6.0"  
 OpenJDK Runtime Environment (build 1.6.0-b09)  
 OpenJDK Client VM (build 1.6.0-b09, mixed mode)  

Hope this helps someone.

Feel free to point out if anything is missing/wrong in this blog.

No comments:

Post a Comment