Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generic-dao dependency #19

Open
ern opened this issue Sep 1, 2016 · 2 comments
Open

Remove generic-dao dependency #19

ern opened this issue Sep 1, 2016 · 2 comments

Comments

@ern
Copy link
Contributor

ern commented Sep 1, 2016

Looks like the only need for gerneric-dao happens to be around transactions:

<bean id="org.sakaiproject.attendance.dao.AttendanceDao" class="org.sakaiproject.genericdao.springutil.CurrentClassLoaderTxProxyFactoryBean">
    <property name="transactionManager" ref="org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager" />
    <property name="target" ref="org.sakaiproject.attendance.dao.AttendanceDaoTarget" />
    <property name="transactionAttributes">
    <props>
        <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
</bean>

Might make sense to just use springs TransactionProxyFactoryBean instead, then you won't need to use a deprecated lib.

@master-bob
Copy link
Collaborator

I attempted to change to using Spring's TransactionProxyFactoryBean (TPFB) like so (similar to how rwiki uses the TPFB):

    <!-- DAO. This uses the DataSource that has already been setup by Sakai  -->
    <bean id="org.sakaiproject.attendance.dao.AttendanceDaoTarget"
          class="org.sakaiproject.attendance.dao.impl.AttendanceDaoImpl"
          init-method="init">
        <property name="sessionFactory" ref="org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory" />
    </bean>

    <!-- Attendance Data Access Object -->
    <bean id="org.sakaiproject.attendance.dao.AttendanceDao"
          class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager" ref="org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager" />
        <property name="target" ref="org.sakaiproject.attendance.dao.AttendanceDaoTarget" />
        <property name="transactionAttributes">
            <props>
                <prop key="get*">PROPAGATION_SUPPORTS,readOnly</prop>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

    <!-- AttendanceLogic -->
    <bean id="org.sakaiproject.attendance.logic.AttendanceLogic"
          class="org.sakaiproject.attendance.logic.AttendanceLogicImpl"
          init-method="init">

        <property name="dao" ref="org.sakaiproject.attendance.dao.AttendanceDao" />
        <property name="sakaiProxy" ref="org.sakaiproject.attendance.logic.SakaiProxy" />
    </bean>

And then was met with an exception on startup:

2016-11-02 13:02:00,980 ERROR localhost-startStop-1 org.sakaiproject.util.NoisierDefaultListableBeanFactory - Failed to preinstantiate the singleton named org.sakaiproject.attendance.logic.
AttendanceLogic. Destroying all Spring beans.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.sakaiproject.attendance.logic.AttendanceLogic' defined in file [/opt/apache-tomcat-8.0.30/compone
nts/attendance-pack/WEB-INF/components.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value o
f type [com.sun.proxy.$Proxy26 implementing org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required typ
e [org.sakaiproject.attendance.dao.AttendanceDao] for property 'dao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy26 implementing 
org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.sakaiproject.attendance.dao.Attendanc
eDao] for property 'dao': no matching editors or conversion strategy found
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.sakaiproject.util.NoisierDefaultListableBeanFactory.preInstantiateSingletons(NoisierDefaultListableBeanFactory.java:73)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.sakaiproject.component.impl.SpringCompMgr.init(SpringCompMgr.java:161)
        at org.sakaiproject.component.cover.ComponentManager.getInstance(ComponentManager.java:115)
        at org.sakaiproject.component.cover.ComponentManager.get(ComponentManager.java:126)
        at org.sakaiproject.component.cover.ServerConfigurationService.getInstance(ServerConfigurationService.java:53)
        at org.sakaiproject.component.cover.ServerConfigurationService.getSakaiHomePath(ServerConfigurationService.java:173)
        at org.sakaiproject.util.ToolListener.contextInitialized(ToolListener.java:66)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1795)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [com.sun.proxy.$Proxy26 implementing org.springframework.beans.factory.Initial
izingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.sakaiproject.attendance.dao.AttendanceDao] for property 'dao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy26 implementing org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.sakaiproject.attendance.dao.AttendanceDao] for property 'dao': no matching editors or conversion strategy found
        at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:476)
        at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
        at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1480)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1220)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
        ... 27 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy26 implementing org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.sakaiproject.attendance.dao.AttendanceDao] for property 'dao': no matching editors or conversion strategy found
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287)
        at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:461)
        ... 33 more
java.lang.Exception: traceback
        at org.sakaiproject.util.NoisierDefaultListableBeanFactory.destroySingletons(NoisierDefaultListableBeanFactory.java:94)
        at org.sakaiproject.util.NoisierDefaultListableBeanFactory.preInstantiateSingletons(NoisierDefaultListableBeanFactory.java:83)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.sakaiproject.component.impl.SpringCompMgr.init(SpringCompMgr.java:161)
        at org.sakaiproject.component.cover.ComponentManager.getInstance(ComponentManager.java:115)
        at org.sakaiproject.component.cover.ComponentManager.get(ComponentManager.java:126)
        at org.sakaiproject.component.cover.ServerConfigurationService.getInstance(ServerConfigurationService.java:53)
        at org.sakaiproject.component.cover.ServerConfigurationService.getSakaiHomePath(ServerConfigurationService.java:173)
        at org.sakaiproject.util.ToolListener.contextInitialized(ToolListener.java:66)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1795)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

Changing the DAO property from
<property name="dao" ref="org.sakaiproject.attendance.dao.AttendanceDao" />
to
<property name="dao" ref="org.sakaiproject.attendance.dao.AttendanceDaoTarget" />
allows start up to complete successfully, but unfortunately does not result in the DAO propagating changes to the backend.

Any suggestions?

So far I've tried making the TPFB abstract and making another bean whose parent is the TPFB (and then updated other beans to use that bean whose parent is the TPFB). Similar to what is used here.

I've also tried changing the order of the bean definitions, but that causes no change; I suspect that the order does not matter.

@ottenhoff
Copy link
Contributor

@ern i couldn't remove genericdao either ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants