0

次のコードは、Eclipse から直接実行すると正常に動作しますが、サーバー (IBM WAS) 上の標準 (Eclipse で生成された) クライアントから呼び出すと、例外が発生します。

  public Dispatcher() { //constructor
            try {           
                ResourceBundle rb = ResourceBundle.getBundle("dispatchersettings", Locale.ENGLISH);
                server = "http://" + rb.getString("UserID") +":" + rb.getString("UserPassword")
                            + "@"+ rb.getString("ServerAppURL") + ":" + rb.getString("ServerAppPort")
                            + rb.getString("ServerAppContextPath"); 
            }
            catch (Exception configException) {
                configException.printStackTrace();
            }
}

public boolean sendTransactionUpdate(String name, String msgTitle, String msgContents, String transORalert) {

        DefaultHttpClient httpclient = new DefaultHttpClient();
        ResponseHandler<String> responseHandler = new BasicResponseHandler(); // auto-reads the response stream
        String responseBody = "";
        try {
            HttpGet httpget = new HttpGet(  new URIBuilder( server + 
                    "/invoke?adapter=rcAdapter&procedure=sendTransactionUpdate")
                    .addParameter("parameters", "[\"" +name +"\",\"" + msgTitle+ "\",\"" + msgContents +"\",\"" + transORalert + "\"]").build() );
            try {
                System.out.println("Inside Webservice :Executing URL -->"  +httpget.toString() );
                responseBody = httpclient.execute(httpget, responseHandler);
                System.out.println( responseBody );
            } catch (Exception e) {
                e.printStackTrace();

            } finally {
                httpget.releaseConnection();
            }
            if( responseBody.indexOf("\"isSuccessful\":true") > -1 )
                return true;
        } catch (Exception e) {
            e.printStackTrace();

        } finally {
            // When HttpClient instance is no longer needed,shut down the connection manager to ensure
            // immediate deallocation of all system resources
            httpclient.getConnectionManager().shutdown();
        }
        return false;
    }

例外:

java.lang.reflect.InvocationTargetException Message: java.lang.reflect.InvocationTargetException

System.out.println("Inside Webservice :Executing URL -->" +httpget.toString() );という行にのみ到達し ます。

responseBody = httpclient.execute(httpget, responseHandler); の前に

上記の行がこの例外を引き起こしているはずだと思います。

キャッチブロックに入らず、例外を表示するのは非常に奇妙です。すぐ下のブロックはまったく実行されていません。

catch (Exception e) {
                System.out.println("Exception LeveL 1:" + e.getMessage() );
                e.printStackTrace();
}

任意の提案をお願いします。

ありがとう

4

1 に答える 1

0

私は今この問題を解決しました。IBM WAS サーバー上の他の jar と衝突する JAR ファイルがありました。おそらくWASの別のjarファイルと衝突していたApache HTTPクライアント(Base64)を使用していました(WASのどのjarファイルかわかりません)。

そこで、jarjar ユーティリティを使用して Apache jar ファイルの名前を変更しました。

その後、プロジェクト内の古い Apache HTTP jar を置き換え、コンパイルして WAS にデプロイしました。そしてそれはうまくいきました。

これが将来誰かを助けることを願っています。

ありがとう

于 2013-06-01T19:33:42.197 に答える