如何解决"引起:org.hibernate.HibernateException:无法访问lob stream"

时间:2018-04-13 11:19:13

标签: java spring hibernate jboss jboss7.x

我最近升级了我的申请。 升级细节:   - Java 6到Java 8   - Hibernate 3到Hibernate 3.6.10   - 春季2.5至春季4   - JBoss EAP 6到JBoss EAP 7

我正在尝试保存一些包含一些文本值和文件(Clob)的值。数据正在保存,但我在下一次休眠操作时遇到异常。

 Caused by: org.hibernate.HibernateException: Unable to access lob stream
    at org.hibernate.type.descriptor.java.ClobTypeDescriptor.unwrap(ClobTypeDescriptor.java:117)
    at org.hibernate.type.descriptor.java.ClobTypeDescriptor.unwrap(ClobTypeDescriptor.java:46)
    at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$3$1.doBind(ClobTypeDescriptor.java:83)
    at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:91)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:283)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:278)
    at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:89)
    at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2184)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2559)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2495)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2822)
    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:113)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at com.honeywell.cdd.dao.RptGrpDAOImpl.removeUnConfigGrpMTDT(RptGrpDAOImpl.java:2373)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:112)
    ... 68 more

 Caused by: java.sql.SQLException: could not reset reader
    at org.hibernate.engine.jdbc.ClobProxy.resetIfNeeded(ClobProxy.java:178)
    at org.hibernate.engine.jdbc.ClobProxy.getCharacterStream(ClobProxy.java:89)
    at org.hibernate.engine.jdbc.ClobProxy.invoke(ClobProxy.java:121)
    at com.sun.proxy.$Proxy133.getCharacterStream(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.hibernate.engine.jdbc.SerializableClobProxy.invoke(SerializableClobProxy.java:74)
    at com.sun.proxy.$Proxy132.getCharacterStream(Unknown Source)
    at org.hibernate.type.descriptor.java.ClobTypeDescriptor.unwrap(ClobTypeDescriptor.java:114)
    ... 98 more

我无法找到此异常的确切原因。

>相同的代码在旧配置中正常工作

1 个答案:

答案 0 :(得分:0)

  

"相同的代码在旧配置中运行良好"

并不真正相关......除非您想向某人提交但报告。

让我们看一下嵌套异常:

  

Caused by: java.sql.SQLException: could not reset reader

stacktrace表示某个东西在Clob代理上调用getCharacterStream(),并且在代理尝试重置代理的阅读器时失败。 (推测)失败是因为代理包装的JDBC对象不允许重置读取器。

为什么会发生这种情况?

再次......大概......应用程序中的某些内容试图在getCharacterStream()代理上调用Clob 两次

我的猜测是你(隐含地)使用Clob个对象就好像它们是内存文件一样......以避免在你不需要时阅读它们。除非有时你需要,否则这会干扰持久性。