Results 1 to 5 of 5

Thread: problems creating an oracle LOB object

  1. #1

    Default problems creating an oracle LOB object

    Hello,

    This forum has been a great help to use Spring on top of Hibernate but now I am stuck
    The problem is that when I'm trying to save (via Junit test) a BLOB object into a column I get the following DataAccessResourceFailureException which is in fact a wrapper for a [java.rmi.MarshalException] :

    Code:
    	at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.getOracleConnection(OracleLobHandler.java:357)
    	at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.createLob(OracleLobHandler.java:328)
    	at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.setBlobAsBytes(OracleLobHandler.java:216)
    	at org.springframework.orm.hibernate.support.BlobByteArrayType.nullSafeSetInternal(BlobByteArrayType.java:98)
    	at org.springframework.orm.hibernate.support.AbstractLobType.nullSafeSet(AbstractLobType.java:143)
    	at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)
    	at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393)
    	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466)
    	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
    	at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
    	at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
    	at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2360)
    	at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
    	at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
    	at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:463)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:373)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:242)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
    	at $Proxy10.storeCaseEvidence(Unknown Source)
    	at be.smalsmvm.genesis.business.service.EvidenceBusinessServiceTest.teststoreCaseEvidence(EvidenceBusinessServiceTest.java:84)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
    Caused by: weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
    [java.rmi.MarshalException: error marshalling return; nested exception is: 
    	java.io.NotSerializableException: oracle.jdbc.driver.LogicalConnection]
    	at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_813_WLStub.getVendorConnection(Unknown Source)
    	at weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_813_WLStub.getVendorConnection(Unknown Source)
    	... 42 more
    First of all I am using : Spring 1.1.1, Weblogic 8.1sp3, oracle 9i, oracle driver = oracle.jdbc.xa.client.OracleXADataSource

    Here's what I have in the applicationContext concerning hibernate and transactions :

    Code:
     <!-- the datasource -->
        <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    	    <property name="jndiTemplate">
        	     <ref local="jndiTemplate" />
             </property>    
    		<property name="jndiName">
    			<value>$&#123;datasource.jndiName&#125;</value>
    		</property>
    	</bean>
    
        <!-- the SessionFactory -->
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource"/>
    		</property>
    		 <property name="lobHandler">
    		 	<ref bean="oracleLobHandler"/>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
    				<prop key="show_sql">false</prop>
    				<prop key="use_outer_join">false</prop>
    			</props>
    		</property>
    		<property name="mappingJarLocations">
    			<list>
    				<value>file&#58;$&#123;genesis.datamodel.jar&#125;</value>
    			</list>
    		</property>
    	</bean>    
         <!-- Database LOB Handling --> 
           <bean name="nativeJdbcExtractor"
            class="org.springframework.jdbc.support.nativejdbc.WebLogicNativeJdbcExtractor"/>     
    
        <bean id="oracleLobHandler"
              class="org.springframework.jdbc.support.lob.OracleLobHandler">
            <property name="nativeJdbcExtractor">
            	<ref bean="nativeJdbcExtractor"/>
           	</property>
        </bean> 
    	<!-- the HibernateTemplate -->
    	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate.HibernateTemplate">
    		<property name="sessionFactory">
    			<ref bean="sessionFactory"/>
    		</property>
    	</bean>
    	<!-- Transaction manager for a single Hibernate SessionFactory &#40;alternative to JTA&#41; -->
        <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
            <property name="sessionFactory">
                <ref local="sessionFactory" />
            </property>
        </bean>
    
         <!-- Transaction Proxy Template --> 
         <bean id="txProxyTemplate" abstract="true"  class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    	    <property name="transactionManager">
    	    	<ref local="transactionManager"/>
    	    </property>
        	<property name="transactionAttributes">
          		<props>
    		        <prop key="*">PROPAGATION_REQUIRED</prop>
    	      </props>
        	</property>
    	  </bean>
    
    <bean id="evidenceBusinessService" parent="txProxyTemplate">        
    		<property name="target">
    			<bean class="be.smalsmvm.genesis.business.service.impl.EvidenceBusinessServiceImpl">
    				<property name="caseDAO">
    			    	<ref local="caseDAO"/>
    			    </property>
    			    <property name="evidenceDAO">
    			    	<ref local="evidenceDAO"/>
    			    </property>
    		 	</bean>
    		</property>
        </bean>
    Is the problem the driver [oracle.jdbc.xa.client.OracleXADataSource] I'm using or the fact that I'm testing this via Junit which extend AbstractSpringContextTests ?

    Any help is highly appreciated and if you need more info let me know !

    Thanks.

    Kristof

  2. #2

    Default problems creating an oracle LOB object

    Apparently I only have this Exception when running my JUnit test locally and not when it's deployed as a .war file on the WebLogic server then everything seems to work out fine...

    So it might have something to do with the oracle driver I'm using locally, mainly : 'ojdbc14_g.jar'.
    Or should I include something in my Junit tests to make it possible to work with the OracleLobHandler ?
    Right now I extend my JUnit test class from Spring's AbstractSpringContextTests....

    Anybody an idea ?
    Thanks.

    Kristof

  3. #3
    Join Date
    Aug 2005
    Posts
    5

    Default Just an idea...

    Since a lot of DB's seem to handle BLOB's differently I decided to use a binary value type instead. I described my implementation at the end of http://forum.springframework.org/showthread.php?t=13663 post. Don't know if it's worth refactoring though if you've already got it working on the server.

    If it ain't broke, don't fix it!

    Brendan
    Last edited by robyn; May 14th, 2006 at 10:37 AM.

  4. #4

    Default

    Thanks for your reply Brendan.

    If it wouldn't work I would have looked into your solution right away
    But as I stated it works when I deploy it on the server but it doesn't work
    when running as a Junit test even though the datasource on the server is beinig used.... Very strange...

    Kristof

  5. #5

    Default

    Instead of using the "WebLogicNativeJdbcExtractor" I've tried to work with the "SimpleNativeJdbcExtractor" :
    Code:
    <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />
    When deployed this works fine but as a Junit this gives me an Exception but a different one as when working with the "WebLogicNativeJdbcExtractor" (see previous thread)...

    Here's the stack-trace :
    Code:
    org.springframework.dao.DataAccessResourceFailureException&#58; Could not create Oracle LOB; nested exception is java.lang.NullPointerException&#58; null
    java.lang.NullPointerException
    	at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.getOracleConnection&#40;OracleLobHandler.java&#58;359&#41;
    	at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.createLob&#40;OracleLobHandler.java&#58;328&#41;
    	at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.setBlobAsBytes&#40;OracleLobHandler.java&#58;216&#41;
    	at org.springframework.orm.hibernate.support.BlobByteArrayType.nullSafeSetInternal&#40;BlobByteArrayType.java&#58;98&#41;
    	at org.springframework.orm.hibernate.support.AbstractLobType.nullSafeSet&#40;AbstractLobType.java&#58;143&#41;
    	at net.sf.hibernate.type.CustomType.nullSafeSet&#40;CustomType.java&#58;118&#41;
    	at net.sf.hibernate.persister.EntityPersister.dehydrate&#40;EntityPersister.java&#58;393&#41;
    	at net.sf.hibernate.persister.EntityPersister.insert&#40;EntityPersister.java&#58;466&#41;
    	at net.sf.hibernate.persister.EntityPersister.insert&#40;EntityPersister.java&#58;442&#41;
    	at net.sf.hibernate.impl.ScheduledInsertion.execute&#40;ScheduledInsertion.java&#58;29&#41;
    	at net.sf.hibernate.impl.SessionImpl.executeAll&#40;SessionImpl.java&#58;2407&#41;
    	at net.sf.hibernate.impl.SessionImpl.execute&#40;SessionImpl.java&#58;2360&#41;
    	at net.sf.hibernate.impl.SessionImpl.flush&#40;SessionImpl.java&#58;2229&#41;
    So now I'm getting a NullPointerException instead and in the spring logging I see a message of "dehydrating entity" and then "the Connection [null] for given Connection handle"

    Code:
    DEBUG &#91;main&#93; &#40;BatcherImpl.java&#58;196&#41; - about to open&#58; 0 open PreparedStatements, 0 open ResultSets
    DEBUG &#91;main&#93; &#40;BatcherImpl.java&#58;237&#41; - insert into EvidenceData &#40;caseEvidenceSetId, comments, data, recordDate, status, typeCode, validdDate, userId, evidenceDataId&#41; values &#40;?, ?, ?, ?, ?, ?, ?, ?, ?&#41;
    DEBUG &#91;main&#93; &#40;BatcherImpl.java&#58;241&#41; - preparing statement
    DEBUG &#91;main&#93; &#40;EntityPersister.java&#58;388&#41; - Dehydrating entity&#58; &#91;be.smalsmvm.genesis.bean.EvidenceData#671&#93;
    DEBUG &#91;main&#93; &#40;NullableType.java&#58;46&#41; - binding '670' to parameter&#58; 1
    DEBUG &#91;main&#93; &#40;NullableType.java&#58;41&#41; - binding null to parameter&#58; 2
    DEBUG &#91;main&#93; &#40;SimpleNativeJdbcExtractor.java&#58;161&#41; - Returning native Connection &#91;null&#93; for given Connection handle &#91;weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_813_WLStub@7&#93;
    So there is DB handling going on for a certain amount of time until the SimpleNativeJdbcExtractor returns null.
    But deployed as a WAR this gives me no problem at all ?!??

    Anybody ? Should I include something in my Junit tests to make it possible to work with a SimpleNativeJdbcExtractor ?

    Thanks for any advice....

    Kristof

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •