Вызов Java из PLSQL, вызывающий oracle.aurora.vm.ReadOnlyObjectException

Внезапно, начиная с 23 декабря, мы получаем ошибку в нашем Production, когда небольшой код Java выполняется из PLSQL:

oracle.aurora.vm.ReadOnlyObjectException

Из того, что мы видим, ничего не изменилось - тот же код работает в нашей среде SIT.

Кто-нибудь видел эту проблему раньше или знает, что вызывает и как ее исправить?

Вызов кода PLSQL:

status_num := TMJ_HTTP_POST(url_chr
                           ,user_id_chr
                           ,password_chr
                           ,wallet_path_chr
                           ,wallet_pass_chr
                           ,send_msg_clob
                           ,received_clb);

PLSQL Wrapper:

CREATE OR REPLACE FUNCTION TMJ_HTTP_POST(url            IN     VARCHAR2
                                    ,username       IN     VARCHAR2
                                    ,password       IN     VARCHAR2
                                    ,walletPath     IN     VARCHAR2
                                    ,walletPassword IN     VARCHAR2
                                    ,sendMsg        IN     CLOB
                                    ,recvMsg        IN OUT CLOB)
RETURN NUMBER
AS LANGUAGE JAVA
  NAME 'TMJ_HTTP.httpPost(java.lang.String
                         ,java.lang.String
                         ,java.lang.String
                         ,java.lang.String
                         ,java.lang.String
                         ,java.sql.Clob
                         ,java.sql.Clob[])
  return int';

Java-код:

create or replace and compile java source named tmj_http as
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.io.Writer;

import java.net.MalformedURLException;
import java.sql.Clob;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.cookie.CookiePolicy;


/**
 * TMJ_HTTP Client
 * utilising the Apache Commons HTTPClient version 3.1 which runs under JDK 1.4
 * which is available in the Oracle 10g database
 *
 * Assumes a file called truststore.cer with password of truststore resides
 * in the same directory as the wallet file
 */
public class TMJ_HTTP
{
  static int timeout = 30000; // 30 second timeout

  public TMJ_HTTP()
  {
  }

  public static int httpPost(String urlStr, String username, String password, String walletLocation, String walletPassword, Clob sendMsgClob, Clob[] recvMsgClob)
  {
    int responseCode = 0;
    StringBuffer sendMsgBuffer = new StringBuffer();
    String sendMsg;
    String[] recvMsg = new String[1];

    try
    {
      // Convert the input Clob to a String
      BufferedReader br = new BufferedReader(sendMsgClob.getCharacterStream());
      String line = null;
      while ((line = br.readLine()) != null)
        sendMsgBuffer.append(line);
      if (br != null)
        br.close();
      sendMsg = sendMsgBuffer.toString();

      responseCode = httpPost(urlStr, username, password, walletLocation, walletPassword, sendMsg, recvMsg);

      // Convert the returned String to the output Clob
      if (recvMsg != null && recvMsg[0] != null)
        recvMsgClob[0].setString(1, recvMsg[0]);
    }
    catch (java.sql.SQLException e)
    {
      responseCode = 501;
    }
    catch (IOException e)
    {
      responseCode = 501;
    }

    return responseCode;
  }


  public static int httpPost(String urlStr, String username, String password, String walletLocation, String walletPassword, String sendMsg, String[] recvMsgArr)
  {
    int responseCode = 0;
    String recvMsg = "";

    /* Uncomment out to allow debugging */
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "debug");
    System.setProperty("javax.net.debug", "SSL");  // Loads of debugging of the SSL connection


    System.getProperties().put("java.protocol.handler.pkgs", "HTTPClient");

    // Define the SSL information
    if (walletLocation != null && walletPassword != null)
    {
      String walletPath = "";
      int pos = walletLocation.lastIndexOf('/');
      if (pos == -1)
        pos = walletLocation.lastIndexOf('\\');
      if (pos >= 0)
        walletPath = walletLocation.substring(0, pos + 1);

      System.setProperty("javax.net.ssl.keyStore", walletLocation);
      System.setProperty("javax.net.ssl.keyStorePassword", walletPassword);
      if (walletLocation.endsWith(".p12"))
        System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
      else
        System.setProperty("javax.net.ssl.keyStoreType", "JKS");
      System.setProperty("javax.net.ssl.trustStore", walletPath + "truststore.cer");
      System.setProperty("javax.net.ssl.trustStorePassword", "truststore");
      System.setProperty("javax.net.ssl.trustStoreType", "JKS");
    }

    HttpClient httpclient = new HttpClient();
    httpclient.getParams().setAuthenticationPreemptive(true);
    // httpclient.getParams().setSoTimeout(timeout);
    // httpclient.getParams().setConnectionManagerTimeout(timeout);

    // Define the authentication information
    Credentials defaultcreds = new UsernamePasswordCredentials(username, password);
    httpclient.getState().setCredentials(AuthScope.ANY, defaultcreds);

    PostMethod method = new PostMethod();

    try
    {
      // Set the Cookie Policy
      method.getParams().setCookiePolicy(CookiePolicy.RFC_2109);

      // Set the URI to post to
      method.setURI(new URI(urlStr, false));

      // Set the header information
      method.addRequestHeader("Content-type", "text/xml; charset=utf-8");
      method.addRequestHeader("User-Agent", "Mozilla/4.0");
      method.addRequestHeader("Accept", "*/*");
      method.addRequestHeader("Connection", "Keep-Alive");
      method.addRequestHeader("Cache-Control", "no-cache");

      // Define the data to send
      method.setRequestBody(sendMsg);

      // Execute the request
      responseCode = httpclient.executeMethod(method);

System.out.println("####### Response Code : " + responseCode);
      if (responseCode == HttpStatus.SC_NOT_IMPLEMENTED)
      {
        // Still Consume the Response Body
        method.getResponseBodyAsString();
      }
      else
      {
System.out.println("####### Reading response buffer");
        // Read the Reply
        BufferedReader br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
        String readLine;
        while(((readLine = br.readLine()) != null))
        {
          recvMsg += readLine;
System.out.println("####### line : " + readLine);
        }
      }
    }
    catch (MalformedURLException e)
    {
      recvMsg = getStackTrace(e);
      responseCode = 501;
    }
    catch (IOException e)
    {
      recvMsg = getStackTrace(e);
      responseCode = 501;
    }
    finally
    {
      // Clean up the system properties.
      System.getProperties().remove("javax.net.ssl.keyStore");
      System.getProperties().remove("javax.net.ssl.keyStorePassword");
      System.getProperties().remove("javax.net.ssl.keyStoreType");
      System.getProperties().remove("javax.net.ssl.trustStore");
      System.getProperties().remove("javax.net.ssl.trustStorePassword");
      System.getProperties().remove("javax.net.ssl.trustStoreType");
      if (method != null)
        method.releaseConnection();
    }

    recvMsgArr[0] = recvMsg;

System.out.println("####### Done - response : " + recvMsg);

    return responseCode;
  }

  public static String getStackTrace(Throwable aThrowable) {
    final Writer result = new StringWriter();
    final PrintWriter printWriter = new PrintWriter(result);
    aThrowable.printStackTrace(printWriter);
    return result.toString();
  }
}

Журнал исключений:

  Algorithm: [SHA1withRSA]
  Signature:
0000: 38 D8 87 DB 8C E1 07 5B   D3 09 FC 5F 44 46 A5 9B  8......[..._DF..
0010: AC E0 03 96 50 FC 3A 03   68 1B CC 9E D6 38 3B EA  ....P.:.h....8;.
0020: BF 00 6C 67 76 17 DA DA   8B 76 61 D7 36 17 C2 65  ..lgv....va.6..e
0030: 86 44 6D AB CE 3C E9 D2   59 01 EB 16 05 89 07 25  .Dm..<..Y......%
0040: E7 16 32 D2 9F 34 2B E7   94 FE 1F F5 03 E5 3A C8  ..2..4+.......:.
0050: CF 3D 53 29 4E 6F 8D 1F   B1 64 20 E9 9C 8A A2 65  .=S)No...d ....e
0060: C5 40 DA 61 EB 61 D7 11   0E 4C 63 D8 11 97 B0 0D  .@.a.a...Lc.....
0070: 2A 70 60 93 B6 21 20 00   CB 12 BF 06 BE AA E9 D0  *p`..! .........
0080: 21 FC B6 5B 89 EB D3 7C   E5 AE 29 20 2B C6 47 F5  !..[......) +.G.
0090: FA C5 04 C6 DB A0 76 61   53 C8 AD C5 39 B1 29 06  ......vaS...9.).
00A0: B9 5A 1E 1D 80 5B 26 3E   E0 06 72 43 36 21 F8 4C  .Z...[&>..rC6!.L
00B0: 23 3A C7 A8 47 FE FE D6   4B D5 BC 3A 8B 04 4E 1A  #:..G...K..:..N.
00C0: 86 7F 92 06 46 64 C4 54   C3 A5 36 25 19 C1 78 3E  ....Fd.T..6%..x>
00D0: C7 BD 85 1C 62 E9 87 06   9A A8 83 FC 88 7F 2D 15  ....b.........-.
00E0: 16 C3 13 EF 3B BB 18 11   77 DD C1 34 BB CE FE 74  ....;...w..4...t
00F0: 25 51 25 77 92 7E A2 55   68 D4 B4 98 D4 A5 00 69  %Q%w...Uh......i

]
Root Thread, handling exception: oracle.aurora.vm.ReadOnlyObjectException
Root Thread, SEND TLSv1 ALERT:  fatal, description = internal_error
Root Thread, WRITE: TLSv1 Alert, length = 2

Полный след здесь: http://pastebin.com/bZZyPTBg

При использовании одного и того же Java-кода извне из базы данных из командной строки он работает нормально.

Спасибо! Стив

0 ответов

Другие вопросы по тегам