出现java.io.NotSerializableException错误。

最近参与了使用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.
//******************************************************************************************

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值