Hi,
I am trying to get the annotational transactionManager working for me.
But I am getting this weird problem, I hope some one can give me a lead
on this.
I am using spring-framework-2.0.6 and
here is part of my applicationContext.xml
Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="txManager"/> <!-- a PlatformTransactionManager is still required --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="beanSessionFactory" /> </bean> <bean id="wijisDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>@database.driver@</value> </property> <property name="jdbcUrl"> <value>@database.url@</value> </property> <property name="user"> <value>@database.user@</value> </property> <property name="password"> <value>@database.password@</value> </property> <property name="minPoolSize"> <value>5</value> </property> <property name="maxPoolSize"> <value>20</value> </property> <property name="maxIdleTime"> <value>600</value> </property> <property name="testConnectionOnCheckout"> <value>false</value> </property> </bean> <bean id="dom4jHibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.hbm2dll.auto">update</prop> <prop key="hibernate.dialect">@hibernate.dialect@</prop> <prop key="hibernate.query.substitutions"> true 'T', false 'F' </prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.default_entity_mode">dom4j</prop><!-- This is needed for the XML <->DB Mapping --> </props> </property> </bean> <bean id="javaHibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.hbm2dll.auto">update</prop> <prop key="hibernate.dialect">@hibernate.dialect@</prop> <prop key="hibernate.query.substitutions"> true 'T', false 'F' </prop> <prop key="hibernate.show_sql">false</prop> </props> </property> </bean> <bean id="beanSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="wijisDataSource" /> </property> <property name="hibernateProperties"> <ref bean="javaHibernateProperties" /> </property> <property name="mappingResources"> <list> <value>UserSession.hbm.xml</value> <value>Jurisdiction.hbm.xml</value> <value>Audit.hbm.xml</value> <value>WijisPointerJava.hbm.xml</value> <value>Organization.hbm.xml</value> <value>Host.hbm.xml</value> <value>Roles.hbm.xml</value> </list> </property> </bean> <bean id="pointerDAOTarget" class="gov.wisconsin.wijis.gateway.persistence.PointerDAOHibernateImpl"> <property name="sessionFactory"> <ref bean="beanSessionFactory" /> </property> <property name="maxRecordsToReturn"><value>500</value></property> <property name="useMaxRecordsField"><value>true</value></property> <property name="directoryForDownload"><value>/usr/local/apache-tomcat-5.5.17/temp/</value></property> <property name="jurisdiction"><ref bean="jurisdictionDAOTarget" /></property> </bean> ... ....
With it, I can deploy the app and all the beans were created. I have not added any
@Transactional to my DAO code yet.
The problem is, I can run the app, but my search, which returns a xml document and we have a chokePointer interceptor on it, breaks.
And here is the error message:
And here is the chokePoint code:Code:2007-08-15 16:56:24,266 DEBUG [gateway.persistence.PointerDAOHibernateImpl] - starting XML search 2007-08-15 16:56:24,325 DEBUG [gateway.persistence.PointerDAOHibernateImpl] - finishing XML search 2007-08-15 16:56:24,542 DEBUG [gateway.persistence.PointerDAOHibernateImpl] - result size:93 2007-08-15 16:56:24,586 ERROR [gateway.serviceimpl.SearchServiceHelperThread] - Search Error java.lang.ClassCastException: org.apache.xmlbeans.impl.store.Xobj$DocumentXobj at gov.wisconsin.wijis.gateway.interceptors.SearchServiceChokepoint.invoke(SearchServiceChokepoint.java:20) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy41.searchPerson(Unknown Source) at gateway.serviceimpl.SearchServiceHelperThread.run(SearchServiceHelperThread.java:67)
Any ideas?Code:package gateway.interceptors; import gateway.serviceimpl.SearchResults; import specs.schemas.gateway.service.search.v11.SearchErrorDocument; import specs.schemas.gateway.service.search.v11.SearchResponseDocument; import specs.schemas.gateway.service.search.v11.SearchTooManyRecordsDocument; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SearchServiceChokepoint implements MethodInterceptor { private static final Log log = LogFactory.getLog(SearchServiceChokepoint.class); private XMLDocumentChokepoint xmlChokepointInstance; public Object invoke (MethodInvocation invocation) throws Throwable { //Here is where search actually gets called SearchResults returnValue = (SearchResults) invocation.proceed(); //It breaks here. //Do post search processing here SearchResponseDocument resultsDocument= returnValue.getResponse(); if (resultsDocument instanceof SearchTooManyRecordsDocument || resultsDocument instanceof SearchErrorDocument) { log.debug("This is not a results doc, don't filter"); return new SearchResults (resultsDocument); } resultsDocument = xmlChokepointInstance.filterXmlDocument(resultsDocument); /* This was burning too many CPU cycles, changed it from DOM4j to xmlbeans Document docFromChokepoint; Document xmlResults = (Document)resultsDocument.getDomNode(); docFromChokepoint = xmlChokepointInstance.filterXmlDocument(xmlResults); SearchResponseDocument searchResponse = SearchResponseDocument.Factory.parse(docFromChokepoint); */ return new SearchResults (resultsDocument); }
Thanks.


Reply With Quote
