Announcement Announcement Module
No announcement yet.
Spring Batch and LDAP? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch and LDAP?

    I would like to write a batch that reads data from db and Ldap server and than writes it ldap server. Is is possible to use Ldap server an input or output source in Spring Batch?

  • #2
    InputSource is merely an interface how you implement it (file, db, ldap, http, r2d2 data interface, c3p0 babble) doesn't matter. So yes but you will have to implement it yourself.


    • #3
      I was thinking about writing an LDAP-aware input source at one point, too. This is a common enough need, and this is a commonly used protocol, so it might be worthwhile to submit a request for this functionality as a JIRA issue. Additionally, you may want to attach your solution for consideration.

      In any case, you'll have to write it yourself for now, so keep posting if you have any questions.


      • #4
        After analyzing samples provided with Spring Batch I think that it'll be better to use ItemProvider/ItemProcessor pattern. ItemProvider will read from db userId and user profile and then ItemProviderProcessTasklet will pass it to ItemProcessor to write attribute.
        However my batch also has to remove profile from users who don't have it in db anymore. This will require more logic - loading all users with given profile and checking if proper entry exists in db. I've been considering putting all this logic in ItemProvider so it would provide just attributes to remove for ItemProcessor.
        What do you think about this solution? I'm new to Spring/Spring Batch ( I only use spring-ldap) so I guess there might be better way to do this.


        • #5
          Any solution for this

          I am new to Spring Batch and trying to read from LDAP and write to DB, It would be great if you could help me with any inputs, Thank you.


          • #6

            I am trying to use Spring Batch(2.2.3.Release) with LDAP. I am also using Spring-Ldap jar(1.3.2.Release) for LDAP operations.
            But somehow getting below exceptions.

            org.springframework.transaction.CannotCreateTransa ctionException: Could not open JDBC Connection for transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHold er] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource] bound to thread [main]
            at org.springframework.jdbc.datasource.DataSourceTran sactionManager.doBegin(DataSourceTransactionManage
            at org.springframework.ldap.transaction.compensating. manager.ContextSourceAndDataSourceTransactionManag er.doBegin(ContextSourceAndDataSourceTransactionMa
            at atformTransactionManager.getTransaction(AbstractPl
            at org.springframework.transaction.interceptor.Transa ctionAspectSupport.createTransactionIfNecessary(Tr
            at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:105)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :172)
            at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
            at com.sun.proxy.$Proxy9.saveUpdateUserDetailMessage( Unknown Source)

            My Batch and ldap configuration is

            <bean id="jobRepository"
            class="org.springframework.batch.core.repository.s upport.JobRepositoryFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="transactionManager" ref="transactionManager" />
            <property name="databaseType" value="MYSQL" />


            <!-- LDAP Transaction Management -->
            <bean id="contextSource" class="org.springframework.ldap.transaction.compen sating.manager.TransactionAwareContextSourceProxy" >
            <constructor-arg ref="contextSourceTarget" />

            <bean id="transactionManager" class="org.springframework.ldap.transaction.compen sating.manager.ContextSourceAndDataSourceTransacti onManager">
            <property name="contextSource" ref="contextSource" />
            <property name="dataSource" ref="dataSource" />

            Is there something wrong with my setup?