6 Replies Latest reply on Jul 1, 2006 10:28 AM by 422368

    Loadjava problem

    13004
      Hi,
      I have a problem when I load my classes using loadjava utility. The following error is raised:
      ORA-29534: referenced object RASTREADOR.net/sourceforge/jtds/jdbc/ConnectionJDBC2 could not be resolved
      errors : class net/sourceforge/jtds/jdbc/MSCursorResultSet
      ORA-29534: referenced object RASTREADOR.net/sourceforge/jtds/jdbc/JtdsStatement could not be resolved
      ORA-29534: referenced object RASTREADOR.net/sourceforge/jtds/jdbc/TdsCore could not be resolved
      ORA-29534: referenced object RASTREADOR.net/sourceforge/jtds/jdbc/TdsData could not be resolved
      ORA-29534: referenced object RASTREADOR.net/sourceforge/jtds/jdbc/ConnectionJDBC2 could not be resolved

      I tried to resolve with command "alter java". But the error insists. I found out that the problem happen because the class java.sql
      could not be found.
                
      SQL> alter java class "net/sourceforge/jtds/jdbc/ConnectionJDBC2" resolve;

      Warning: Java altered with compilation errors.

      SQL> show errors
      Errors for JAVA CLASS /2c65331e_ConnectionJDBC23:

      LINE/COL ERROR
      -------- -----------------------------------------------------------------
      0/0 ORA-29521: referenced name java/sql/Savepoint could not be found


      I think my problem is configuration.

      I'm using java version "1.4.2_04"

      Thanks in advance.
        • 1. Re: Loadjava problem
          Avi Abrami
          Paulo,
          "java.sql.Savepoint" exists only since java version 1.4, and only Oracle 10g database JVM is campatible with java version 1.4. Hence you either need to use the Oracle 10g databae, or not use the "Savepoint" interface.

          Good Luck,
          Avi.
          • 2. Re: Loadjava problem
            107498
            Hi, I'm experiencing exactly the same problem but I am using Oracle 10g (10.2.0.1.0).

            SQL> alter java class "net/sourceforge/jtds/jdbc/ConnectionJDBC2" resolve;

            Warning: Java altered with compilation errors.

            SQL> show errors
            Errors for JAVA CLASS /c6ce91c2_ConnectionJDBC2:

            LINE/COL ERROR
            -------- -----------------------------------------------------------------
            0/0 ORA-29521: referenced name java/sql/Savepoint could not be found

            Any help appreciated.

            Thanks,

            Paul.
            • 3. Re: Loadjava problem
              107498
              Some more information - as the driver I'm trying to load into the database (jTDS SQL Server driver) uses the classes java.sql .ParameterMetaData and java.sql.Savepoint, I tried to get around the problem by going to the source code of the jTDS driver. Here I located the jar file jdbc3_0-ext.jar. This jar contains the above classes. I loaded this jar in using loadjava. The jTDS driver then finally loaded using loadjava with no errors.

              When running a small test class now I get the following error:

              ORA-29532: Java call terminated by uncaught Java exception:
              java.lang.InternalError: Prohibited package name: java.sql

              This, I think, is to do with the classes defined as being part of java.sql (i.e. those I loaded above) but not actually being part of the java.sql package. According to Sun, the ClassLoader class is hard-coded to refuse to load classes prefixed with "java." as a protection mechanism - ref: http://java.sun.com/developer/JDCTechTips/2001/tt0130.html

              So I still need to have access to the java.sql classes mentioned above and according to a previous post here they're part of JVM 1.4 so I'm figuring I shouldn't have had to load those two classes explicitly - as I'm using 10g rel 2.

              Any ideas?

              Thanks.
              • 4. Re: Loadjava problem
                Avi Abrami
                Paul,
                Does this help you:
                SQL*Plus: Release 10.1.0.4.0 - Production on Mon Mar 13 14:18:57 2006
                
                Copyright (c) 1982, 2005, Oracle.  All rights reserved.
                
                
                Connected to:
                Oracle Database 10g Release 10.1.0.4.0 - 64bit Production
                
                
                SQL> select DBMS_JAVA.LONGNAME(OBJECT_NAME) as OBJECT_NAME
                  2    from ALL_OBJECTS
                  3   where OBJECT_NAME like '%Savepoint%'
                  4     and OBJECT_TYPE like '%JAVA%';
                
                OBJECT_NAME
                --------------------------------------------------------------------------------
                oracle/jdbc/driver/OracleSavepoint
                oracle/jdbc/OracleSavepoint
                java/sql/Savepoint
                And I didn't load any third-party JDBC drivers into my database.

                If you are trying to use JDBC to link an Oracle database with a SQL Server database, I believe Oracle already has tools to accomplish that task. "Transparent Gateways" is something that comes to mind. Perhaps you could do a search for that?

                Good Luck,
                Avi.
                • 5. Re: Loadjava problem
                  107498
                  Thanks Avi, yes it does help.

                  I'd thought about using gateways but settled on JDBC - thinking it simpler to set up (possibly got that one wrong then!!).

                  I've got them loaded now though. For info, the classes I needed were in the db as you said. My problem was the resolution so I changed the loadjava command to the following to ensure correct resolution:

                  loadjava -user dbauser/pw@mydatabase -verbose -force -grant MY_USER -synonym -resolve -resolver "((* PUBLIC) (* SYS) (* MY_USER))" -schema MY_USER "C:\Program Files\jTDS\jtds-1.2.jar"

                  Then once loaded I have to run the following grants to get the thing to work:

                  dbms_java.grant_permission('MY_USER','SYS:java.net.SocketPermission', 'sqlserverhost', 'CONNECT,RESOLVE');
                  dbms_java.grant_permission('MY_USER','SYS:java.net.SocketPermission', '192.168.2.15:1433', 'CONNECT,RESOLVE');
                  dbms_java.grant_permission('MY_USER','SYS:java.lang.RuntimePermission', 'getClassLoader', '' );

                  Cheers,

                  Paul.
                  • 6. Re: Loadjava problem
                    422368
                    Hello,

                    I tried your method of loadjava, hwoever I am getting error

                    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/Or
                    acleDriver
                    at oracle.aurora.server.tools.loadjava.DatabaseOptions.connect(DatabaseO
                    ptions.java:109)
                    at oracle.aurora.server.tools.loadjava.LoadJavaState.getConnection(LoadJ
                    avaState.java:391)
                    at oracle.aurora.server.tools.loadjava.Base.getConnection(Base.java:27)
                    at oracle.aurora.server.tools.loadjava.JdbcOperations.userExists(JdbcOpe
                    rations.java:290)
                    at oracle.aurora.server.tools.loadjava.LoadJava.checkUserExists(LoadJava
                    .java:132)
                    at oracle.aurora.server.tools.loadjava.LoadJava.initialize(LoadJava.java
                    :156)
                    at oracle.aurora.server.tools.loadjava.LoadJava.parseArgs(LoadJava.java:
                    205)
                    at oracle.aurora.server.tools.loadjava.LoadJava.command(LoadJava.java:23
                    2)
                    at oracle.aurora.server.tools.loadjava.LoadJavaMain.run(LoadJavaMain.jav
                    a:103)
                    at oracle.aurora.server.tools.loadjava.LoadJavaMain.main(LoadJavaMain.ja
                    va:28)