facebook

Security scaffolding removing beans in generated-dao-context

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #314457 Reply

    Eddy
    Participant

    Unfortunately it appears that the Spring Security scaffolding has issues in regards to the generated generated-dao-context.xml.
    I have an existing project that originally was started using Spring CRUD scaffolding accessing a MySQL database for the security info “MotorHeadSecurity”. The before Spring Security scaffolding project was fully functional and was connected to a database “MotorHead” after the Spring Security scaffolding the bean: “MotorHeadDS” was removed but references left. I have included both the before and after generated-dao-context.xml files. Any help in how to work around this issue would be greatly appreciated.

    ====== begin before security scaffolding generated-dao-context.xml====
    <?xml version=”1.0″ encoding=”UTF-8″?>
    <beans xmlns=”http://www.springframework.org/schema/beans&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xmlns:tx=”http://www.springframework.org/schema/tx&#8221;
    xmlns:aop=”http://www.springframework.org/schema/aop&#8221;
    xmlns:jee=”http://www.springframework.org/schema/jee&#8221;
    xmlns:context=”http://www.springframework.org/schema/context&#8221;
    xmlns:security=”http://www.springframework.org/schema/security&#8221;
    xsi:schemaLocation=”http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/jee
    http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-2.0.1.xsd”&gt;

    <!– ******************************************************************** –>
    <!– This context file was generated and is not intended to be changed manually. –>
    <!– ******************************************************************** –>

    <!– ******************************************************************** –>
    <!– Scan for dao layer annotated beans –>
    <!– ******************************************************************** –>
    <context:component-scan base-package=”com.ipei.traveler.collector.dao” scoped-proxy=”interfaces” />

    <!– ******************************************************************** –>
    <!– Mark bean transactions as annotation driven –>
    <!– ******************************************************************** –>
    <tx:annotation-driven transaction-manager=”transactionManager” />

    <!– ******************************************************************** –>
    <!– PropertyConfigurer for the DAO –>
    <!– ******************************************************************** –>
    <bean id=”propertyConfigurer” class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
    <property name=”location” value=”classpath:collector-dao.properties” />
    </bean>

    <!– ******************************************************************** –>
    <!– Setup the transaction manager –>
    <!– ******************************************************************** –>
    <!– Using Atomikos Transaction Manager –>
    <bean id=”atomikosTransactionManager” class=”com.atomikos.icatch.jta.UserTransactionManager” init-method=”init”
    destroy-method=”close”>
    <property name=”forceShutdown” value=”true” />
    <property name=”startupTransactionService” value=”true” />
    <property name=”transactionTimeout” value=”60″ />
    </bean>

    <bean id=”atomikosUserTransaction” class=”com.atomikos.icatch.jta.UserTransactionImp” />

    <!– Configure the Spring framework to use JTA transactions from Atomikos –>
    <bean id=”transactionManager” class=”org.springframework.transaction.jta.JtaTransactionManager”>
    <property name=”transactionManager” ref=”atomikosTransactionManager” />
    <property name=”userTransaction” ref=”atomikosUserTransaction” />
    <property name=”transactionSynchronizationName” value=”SYNCHRONIZATION_ON_ACTUAL_TRANSACTION” />
    </bean>
    <!– ******************************************************************** –>
    <!– Setup each data source –>
    <!– ******************************************************************** –>
    <!– Using Atomikos Data Sources –>

    <bean name=”MotorHeadDS” class=”com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean” >
    <property name=”uniqueResourceName” value=”MotorHead__KDQl4MIsEd-ka7MfBBvw0Q” />
    <property name=”driverClassName” value=”${MotorHead.connection.driver_class}” />
    <property name=”user” value=”${MotorHead.connection.username}” />
    <property name=”password” value=”${MotorHead.connection.password}” />
    <property name=”url” value=”${MotorHead.connection.url}” />
    <property name=”minPoolSize” value=”${MotorHead.minPoolSize}” />
    <property name=”maxPoolSize” value=”${MotorHead.maxPoolSize}” />
    </bean>

    <!– ******************************************************************** –>
    <!– Setup each persistence unit –>
    <!– ******************************************************************** –>
    <!– Using Hibernate Persistence Units –>

    <!– Configure a JPA vendor adapter –>
    <bean id=”MotorHeadJPAVendorAdapter” class=”org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter”>
    <property name=”showSql” value=”${MotorHead.show_sql}” />
    <property name=”generateDdl” value=”${MotorHead.generateDdl}” />
    <property name=”databasePlatform” value=”${MotorHead.dialect}” />
    </bean>
    <!– EntityManager Factory that brings together the persistence unit, datasource, and JPA Vendor –>
    <bean id=”MotorHead” class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean”>
    <property name=”dataSource” ref=”MotorHeadDS” />
    <property name=”persistenceUnitName” value=”MotorHead” />
    <property name=”jpaVendorAdapter” ref=”MotorHeadJPAVendorAdapter” />
    <property name=”jpaPropertyMap”>
    <map>
    <entry key=”hibernate.transaction.manager_lookup_class” value=”com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup” />
    <entry key=”hibernate.connection.release_mode” value=”on_close” />
    </map>
    </property>
    </bean>

    </beans>

    ====== end before security scaffolding generated-dao-context.xml====
    ====== begin after security scaffolding generated-dao-context.xml====

    <?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
    <beans xmlns=”http://www.springframework.org/schema/beans&#8221; xmlns:aop=”http://www.springframework.org/schema/aop&#8221; xmlns:context=”http://www.springframework.org/schema/context&#8221; xmlns:jee=”http://www.springframework.org/schema/jee&#8221; xmlns:security=”http://www.springframework.org/schema/security&#8221; xmlns:tx=”http://www.springframework.org/schema/tx&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd”&gt;

    <!– ******************************************************************** –>
    <!– This context file was generated and is not intended to be changed manually. –>
    <!– ******************************************************************** –>

    <!– ******************************************************************** –>
    <!– Scan for dao layer annotated beans –>
    <!– ******************************************************************** –>
    <context:component-scan base-package=”com.ipei.traveler.collector.dao” scoped-proxy=”interfaces”/>
    <context:component-scan base-package=”com.ipei.traveler.collector.security” scoped-proxy=”interfaces”/>

    <!– ******************************************************************** –>
    <!– Mark bean transactions as annotation driven –>
    <!– ******************************************************************** –>
    <tx:annotation-driven transaction-manager=”transactionManager”/>

    <!– ******************************************************************** –>
    <!– PropertyConfigurer for the DAO –>
    <!– ******************************************************************** –>
    <bean class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer” id=”propertyConfigurer”>
    <property name=”location” value=”classpath:collector-dao.properties”/>
    </bean>

    <!– ******************************************************************** –>
    <!– Setup the transaction manager –>
    <!– ******************************************************************** –>
    <!– Using Atomikos Transaction Manager –>
    <bean class=”com.atomikos.icatch.jta.UserTransactionManager” destroy-method=”close” id=”atomikosTransactionManager” init-method=”init”>
    <property name=”forceShutdown” value=”true”/>
    <property name=”startupTransactionService” value=”true”/>
    <property name=”transactionTimeout” value=”60″/>
    </bean>

    <bean class=”com.atomikos.icatch.jta.UserTransactionImp” id=”atomikosUserTransaction”/>

    <!– Configure the Spring framework to use JTA transactions from Atomikos –>
    <bean class=”org.springframework.transaction.jta.JtaTransactionManager” id=”transactionManager”>
    <property name=”transactionManager” ref=”atomikosTransactionManager”/>
    <property name=”userTransaction” ref=”atomikosUserTransaction”/>
    <property name=”transactionSynchronizationName” value=”SYNCHRONIZATION_ON_ACTUAL_TRANSACTION”/>
    </bean>

    <!– ******************************************************************** –>
    <!– Setup a data source –>
    <!– ******************************************************************** –>

    <!– Using Apache DBCP Data Sources –>
    <bean class=”org.apache.commons.dbcp.BasicDataSource” destroy-method=”close” name=”MotorHeadSecurityDS,springSecurityDataSource”>
    <property name=”driverClassName” value=”${MotorHeadSecurity.connection.driver_class}”/>
    <property name=”username” value=”${MotorHeadSecurity.connection.username}”/>
    <property name=”password” value=”${MotorHeadSecurity.connection.password}”/>
    <property name=”url” value=”${MotorHeadSecurity.connection.url}”/>
    <property name=”maxIdle” value=”${MotorHeadSecurity.minPoolSize}”/>
    <property name=”maxActive” value=”${MotorHeadSecurity.maxPoolSize}”/>
    </bean>

    <!– ******************************************************************** –>
    <!– Setup each persistence unit –>
    <!– ******************************************************************** –>

    <!– Configure a JPA vendor adapter –>
    <bean class=”org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter” id=”MotorHeadJPAVendorAdapter”>
    <property name=”showSql” value=”${MotorHead.show_sql}”/>
    <property name=”generateDdl” value=”${MotorHead.generateDdl}”/>
    <property name=”databasePlatform” value=”${MotorHead.dialect}”/>
    </bean>
    <bean class=”org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter” id=”MotorHeadSecurityJPAVendorAdapter”>
    <property name=”showSql” value=”${MotorHeadSecurity.show_sql}”/>
    <property name=”generateDdl” value=”${MotorHeadSecurity.generateDdl}”/>
    <property name=”databasePlatform” value=”${MotorHeadSecurity.dialect}”/>
    </bean>
    <!– EntityManager Factory that brings together the persistence unit, datasource, and JPA Vendor –>
    <bean class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean” id=”MotorHead”>
    <property name=”dataSource” ref=”MotorHeadDS”/>
    <property name=”persistenceUnitName” value=”MotorHead”/>
    <property name=”jpaVendorAdapter” ref=”MotorHeadJPAVendorAdapter”/>
    <property name=”jpaPropertyMap”>
    <map>
    <entry key=”hibernate.transaction.manager_lookup_class” value=”com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup”/>
    <entry key=”hibernate.connection.release_mode” value=”on_close”/>
    </map>
    </property>
    </bean>
    <bean class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean” id=”MotorHeadSecurity”>
    <property name=”dataSource” ref=”MotorHeadSecurityDS”/>
    <property name=”persistenceUnitName” value=”MotorHeadSecurity”/>
    <property name=”jpaVendorAdapter” ref=”MotorHeadSecurityJPAVendorAdapter”/>
    <property name=”jpaPropertyMap”>
    <map>
    <entry key=”hibernate.transaction.manager_lookup_class” value=”com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup”/>
    <entry key=”hibernate.connection.release_mode” value=”on_close”/>
    </map>
    </property>
    </bean>

    </beans>

    ====== end after security scaffolding generated-dao-context.xml====

    #314777 Reply

    jayperkins
    Member

    This appears to be a bug when we merge the generated-dao.xml file. I will create a JIRA.

    You could copy back the missing MotorheadDAO bean definition (if you are still using it) or remove the MotorHeadJPAVendorAdapter and the MotorHead bean definitions if you are only using the MotorHeadSecurityDS.

    I’m not sure if this totally answers your question so let me know if I can provide any more assistance?

    Thanks,
    Jay

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Security scaffolding removing beans in generated-dao-context

You must be logged in to post in the forum log in