5 Replies Latest reply: Jun 6, 2013 1:54 AM by gimbal2 RSS

    ORA-29552: verification warning: java.lang.UnsupportedClassVersionError

    9423755
      Hi
      I'm trying to load a class file into Oracle using loadjava and I get the following error:

      ORA-29552: verification warning: java.lang.UnsupportedClassVersionError: helloworld (Unsupported major.minor version 51.0)

      Presumably this is related to an inconsistency between the jdk that I used to compile helloworld and the Oracle JVM? Or something like that?

      My JAVA_HOME is C:\Program Files (x86)\Java\jre7\bin
      My javac version used to compile the code is javac 1.7.0_15
      java -version is "1.7.0_15"
      When I do a find on java.exe in the oracle installation directory (I'm running 11.2) I get

      J-PC:J >find -name java.exe
      ./product/11.2.0/dbhome_1/jdk/bin/java.exe
      ./product/11.2.0/dbhome_1/jdk/jre/bin/java.exe
      ./product/11.2.0/dbhome_1/jre/1.5.0/bin/java.exe

      Finally, the jdbc jar is ojdbc6.jar

      Btw the code is just the usual little tester:
      import oracle.jdbc.driver.*;
      
      public class helloworld {
      
          public static String hello()
          {
              return "Hello World";
          }
      
          public static String hello(String s)
          {
              return "Hello " + s ;
          }    
          
          public static void main(String[] args)
          {
              helloworld.hello();
              helloworld.hello("Larry");
          }
      }
      How can I get this class file loaded? Many thanks,
      Jason
        • 1. Re: ORA-29552: verification warning: java.lang.UnsupportedClassVersionError
          gimbal2
          Oracle 11 has Java 5 embedded, not Java 7. You'll have to compile your classes for java 1.5 compatibility (using the -target compiler command line switch), or for epic laziness install a Java 5 JDK.

          And predicting a followup question: no, you cannot upgrade the embedded JDK.
          Finally, the jdbc jar is ojdbc6.jar
          Eh? What does ojdbc have to do with loadjava?
          • 2. Re: ORA-29552: verification warning: java.lang.UnsupportedClassVersionError
            rp0428
            >
            Eh? What does ojdbc have to do with loadjava?
            >
            And that would likely be this
            >
            import oracle.jdbc.driver.*;
            >
            Those classes are in the Oracle JDBC jar file.

            The database JVM will be using the equivalent of ojdbc5.jar so if OP is using any of the ojdb6.jar functionality that isn't in the older jar file they will have problems.
            • 3. Re: ORA-29552: verification warning: java.lang.UnsupportedClassVersionError
              rp0428
              >
              How can I get this class file loaded?
              >
              I suggest that you load the source file instead. As gimbal2 said all class files in the database MUST be compatible with the internal JVM used by the database. For 11g versions that is Java 1.5 and the major version in Java 1.5 class files is 49.

              You also need to take the same version issue into account if you need to load any jar files into the DB. That load won't be successful if any of those classes were compiled for a later version of Java compatibility.;

              If you load the source file and compile the DB JVM will be used and you won't get that exception. You will also ensure that you are using the correct supporting classes; for example those JDBC driver classes you are importing will be the JVM versions and those will NOT be the same as those in ojdbc6.jar.

              You need to make sure you are not currently using JDBC classes or functionality that are not available in the DB version of the driver.

              Using Java and JDBC in the database means you might be able to take advantage of Oracle's internal JDBC driver. See the 'Server-Side Internal Driver' chapter of the JDBC Dev Guide for details.
              http://docs.oracle.com/cd/B28359_01/java.111/b31224.pdf
              Overview of the Server-Side Internal Driver
              The server-side internal driver is intrinsically tied to Oracle Database and to the Java
              Virtual Machine (JVM). The driver runs as part of the same process as the database. It
              also runs within the default session, the same session in which the JVM was started.
              
              The server-side internal driver is optimized to run within the database server and
              provide direct access to SQL data and PL/SQL subprograms on the local database. The
              entire JVM operates in the same address space as the database and the SQL engine.
              Access to the SQL engine is a function call. This enhances the performance of your
              Java Database Connectivity (JDBC) applications and is much faster than running a
              remote Oracle Net call to access the SQL engine.
              
              The server-side internal driver supports the same features, application programming
              interfaces (APIs), and Oracle extensions as the client-side drivers. This makes
              application partitioning very straightforward. For example, if you have a Java
              application that is data-intensive, then you can easily move it into the database server
              for better performance, without having to modify the application-specific calls.
              • 4. Re: ORA-29552: verification warning: java.lang.UnsupportedClassVersionError
                9423755
                Ok guys, thanks, I loaded the java file into the db rather than the class file and it worked, no problems.

                Thanks,
                Jason
                • 5. Re: ORA-29552: verification warning: java.lang.UnsupportedClassVersionError
                  gimbal2
                  Jason_942375 wrote:
                  Ok guys, thanks, I loaded the java file into the db rather than the class file and it worked, no problems.
                  I didn't realize that loadjava could also compile a source file. That certainly makes it more "I don't want to understand it"-proof.