出現java.io.NotSerializableException錯誤。

來源:互聯網
上載者:User

最近參與了使用JAVA語言開發的項目,開發環境是MyEclipse + WebLogic。

自己也發了幾個文章介紹了一下使用到的一些技術。

如何在JAVA程式中使用Struct一次傳入多條資料給Oracle的預存程序。

如何以Collection變數作為資料來源來向資料表中插入資料,或者更新資料。

如何在Oracle中修改Collection類型的變數。

如何在Oracle中向Collection類型的變數中逐條插入資料。

但是在進行UT的時候下面的代碼無法通過。

StructDescriptor st = new StructDescriptor("DEPARTMENT_TYPE",dbConn);

出現的錯誤是:

Caused by: java.rmi.MarshalException: error marshalling return; nested exception is: 
    java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)

出現這樣問題的原因都是有對象沒有進行序列化。我們出現這個問題的現象是:進行UT時程式無法運行,但是從JSP頁面進行調用就沒有問題。所以分析的結果是我們寫的項目架構中用於UT的部分沒有繼承序列化或者Struct本身沒有繼承序列化。

參考:

http://forums.bea.com/thread.jspa?messageID=600034901&tstart=0
http://forums.bea.com/thread.jspa?messageID=400006195
http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1043705
http://e-docs.bea.com/wls/docs81/jdbc/programming.html#1054307
//******************************************************************************************
To obtain a connection for a JDBC client, use a Java Naming and Directory Interface (JDNI) lookup to locate the DataSource object, as shown in the following code fragment.
Note: When using a JDBC connection in a client-side application, the exact same JDBC driver classes must be in the CLASSPATH on both the server and the client. If the driver classes do not match, you may see java.rmi.UnmarshalException exceptions.
//******************************************************************************************

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.