This discussion is archived
6 Replies Latest reply: Oct 30, 2012 1:51 AM by Tolls RSS

Problem with calling java in Oracle 11g r2

963306 Newbie
Currently Being Moderated
Hello, i`m having a problem with imported java classes to my oracle database. I`m trying to invoke a method from a java class ( radek.class ). That class is using other classes ( i loaded them as jar files to database using loadjava ). Everything looks fine, compiled with status valid. When i`m trying to call a method from class using pl/sql function i got this error :

ORA-29516: Niepowodzenie asercji Aurora: Assertion failure at eox.c:359
Uncaught exception System error: java/lang/UnsupportedClassVersionError
ORA-06512: przy "RADEK.DAWAJ", linia 1
ORA-06512: przy linia 4

I was thinking is a problem with jvm or jdk versions. i compiled these classes with jdk 1.6,1.7 and still the same problem.

version of my java in oracle:
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)

Please help me,
  • 1. Re: Problem with calling java in Oracle 11g r2
    gimbal2 Guru
    Currently Being Moderated
    You would be correct - the DBMS has Java 5 embedded without a possibility to upgrade. You should be able to compile compatible classes using the -source and -target parameters of javac.
  • 2. Re: Problem with calling java in Oracle 11g r2
    rp0428 Guru
    Currently Being Moderated
    >
    version of my java in oracle:
    java version "1.7.0_06"
    Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
    Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
    >
    No it isn't - Oracle ships with Java 1.5 and it simply isn't possible for you to update it correctly. If you did try to update it then you have likely broken Oracle itself and may need to reinstall it.

    See my reply in this thread
    Re: upgrading Server-Side, Oracle DB JVM
    >
    The JVM is an integral part of Oracle and without the proper, certified version of the JVM the database will not run properly. In fact if you use Oracle installer and elect to remove the JVM the database itself will be removed also.

    Oracle 11g installs with JDK 1.5 and that is the ONLY version that is certified to work properly with 11g. If you attempt to use anyother version you are violating your support contract and will likely have errors.

    The installed version of the JDK is the version that Oracle itself uses and is the version that will be used for any Java classes that you load into the database and run from within Oracle.

    You are free to use any version of the JDK you want for external Java applications.
  • 3. Re: Problem with calling java in Oracle 11g r2
    963306 Newbie
    Currently Being Moderated
    Thanks for reply. Now i understand but i have some new problems... The strange thing is that i can`t downgrade my project. I tryed to compile in netbeans with 1.5 jdk and got this error, maybe someone can help me?

    cd C:\test\biojava-3.0.4-all\bj3.0.4\biojava3-structure; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.5.0_22" "\"C:\\Program Files\\NetBeans 7.2\\java\\maven\\bin\\mvn.bat\"" clean install

    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project biojava3-structure: Compilation failure
    C:\test\biojava-3.0.4-all\bj3.0.4\biojava3-structure\src\main\java\org\biojava\bio\structure\scop\ScopInstallation.java:[46,-1] cannot access org.biojava3.core.util.InputStreamProvider
    bad class file: C:\Users\JA\.m2\repository\org\biojava\biojava3-core\3.0.4\biojava3-core-3.0.4.jar(org/biojava3/core/util/InputStreamProvider.class)
    class file has wrong version 50.0, should be 49.0

    how i can recompile? these class is importing many of other classes.. i know i should use javac -target but some classes are in other source packages. Should i get all classes in 1 folder, then use javac -target?
    I was trying to find soultion on netbeans forum but no one answered.
  • 4. Re: Problem with calling java in Oracle 11g r2
    rp0428 Guru
    Currently Being Moderated
    >
    I tryed to compile in netbeans with 1.5 jdk and got this error, maybe someone can help me?

    cd C:\test\biojava-3.0.4-all\bj3.0.4\biojava3-structure; "JAVA_HOME=C:
    Program Files\\Java
    jdk1.5.0_22" "\"C:
    Program Files
    NetBeans 7.2\\java\\maven\\bin\\mvn.bat\"" clean install

    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project biojava3-structure: Compilation failure
    C:\test\biojava-3.0.4-all\bj3.0.4\biojava3-structure\src\main\java\org\biojava\bio\structure\scop\ScopInstallation.java:[46,-1] cannot access org.biojava3.core.util.InputStreamProvider
    bad class file: C:\Users\JA\.m2\repository\org\biojava\biojava3-core\3.0.4\biojava3-core-3.0.4.jar(org/biojava3/core/util/InputStreamProvider.class)
    class file has wrong version 50.0, should be 49.0
    >
    That issue is because classes compiled with Java 1.6 (and with target 1.6) will have 50 as the major version number embedded in the class files. Java 1.5 compiled classes will have 49 as the major version.

    You can't run 1.6 classes (50 version) in 1.5 so that is the cause of the error.

    Oracle DB comes with, AND REQUIRES, 1.5 and, as said before, you CANNOT upgrade it or you will break Oracle itself.

    So if the Java code needs to run within the database you cannot use features from 1.6 - there is no workaround.

    See this wiki for the list of Java versions and the class file versions used.
    http://en.wikipedia.org/wiki/Java_class_file
  • 5. Re: Problem with calling java in Oracle 11g r2
    gimbal2 Guru
    Currently Being Moderated
    Of course the error message could have been made a lot more helpful, I don't really blame the OP for not understanding it right away. Of course nothing a quick Google search couldn't have solved.
  • 6. Re: Problem with calling java in Oracle 11g r2
    Tolls Journeyer
    Currently Being Moderated
    "cannot access org.biojava3.core.util.InputStreamProvider
    bad class file: C:\Users\JA\.m2\repository\org\biojava\biojava3-core\3.0.4\biojava3-core-3.0.4.jar(org/biojava3/core/util/InputStreamProvider.class)
    class file has wrong version 50.0, should be 49.0
    "

    You're importing a package, which looks like one of your other projects.
    That is (as pointed out) compiled in 1.6.
    You're going to have to produce 1.5 versions of all your dependencies, and ensure any third party dependencies are also 1.5.
    So your build tool (whichever one you're using) will need to be changed to produce a 1.5 and everything this current project depends on will need to be rebuilt.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points