Need help setting up properties for ActiveDirectoryLdapAuthenticationProvider - java

My properties no longer work with spring.
The error I get is:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapActiveDirectoryAuthProvider' defined in class path resource [application-context-security.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'user-search-base' of bean class [org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider]: Bean property 'user-search-base' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.wm.Ldap.AuthenticationExample.main(AuthenticationExample.java:38)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'user-search-base' of bean class [org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider]: Bean property 'user-search-base' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperI
mpl.java:924)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
... 13 more
Here is my code:
<bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<constructor-arg value="someurl" />
<constructor-arg value="ldaps://someurl" />
<property name="user-search-base" value=""/>
<property name="user-search-filter" value="(sAMAccountName={0})"/>
<property name="group-search-base" value="ou=blahblah"/>
<property name="group-search-filter" value="member={0}"/>
<property name="role-prefix" value="ROLE_"/>
<property name="user-details-class" value="person"/>
</bean>

All the property names you've specified are invalid, property names cannot have dashes in them (since they map to setters).

"user-search-base" should contain somethig like
"OU=myou,dc=xx,dc=yy"

Related

Why ambiguity when I inject argument for multiple constructors?

Why does this happen when I define two constructors, one of which has referenced parameter, and another a primitive parameter?
Below are relevant snippets.
Constructor 1:
public TextEditor(SpellChecker sc) {...}
Constructor 2:
public TextEditor(int editorNum) {...}
bean definition xml file:
...
<constructor-arg ref="spellChecker"/> <!--spellChecker is defined as class elsewhere-->
<constructor-arg value="100"/>
...
Compiling error of ambiguities remains even when I add type/name/index to the tag.
post full stack trace below
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'textEditor' defined in class path resource [Beans.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.tutorialspoint.MainApp.main(MainApp.java:7)
Proper constructor injection through applicationContext.xml will be like this :
For example : Suppose your TextEditor & SpellChecker classes are in the package com.test.
Now, the xml will look like :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Create a SpellChecker bean -->
<bean id = "spellChecker" class="com.test.SpellChecker"/>
<!-- Create a TextEditor bean by calling the first constructor -->
<bean id="textEditor" class="com.test.TextEditor" >
<constructor-arg ref="spellChecker"/>
</bean>
<!-- Create a TextEditor bean by calling the second constructor -->
<bean id="textEditor_1" class="com.test.TextEditor" >
<constructor-arg value="100"/>
</bean>
</beans>
Hope this helps you :)
Thanks.

Why do I get "Failed to convert property value" for a Bean in Spring batch

I have three steps in my Spring Batch project and all three has reader, writer, processor. First two step has identical readers and processors and writers. However third step's writer is slightly different. Please see below
<bean id="stepWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
<property name="dataSource" ref="dataSource" />
<property name="sql">
<value>
<![CDATA[
insert into step(tst_id)
values (?);
]]>
</value>
</property>
<property name="ItemPreparedStatementSetter">
<bean class="com.preparedstatement.StepWriter" />
</property>
</bean>
<batch:step id="step3">
<batch:tasklet transaction-manager="transactionManager">
<batch:chunk reader="xmlItemReaderStep2" writer="stepWriter"
processor="itemProcessor4" commit-interval="100" />
<batch:listeners>
<batch:listener ref="jobListener4" />
</batch:listeners>
</batch:tasklet>
</batch:step>
<batch:listeners>
<batch:listener ref="jobListener1" />
</batch:listeners>
</batch:job>
And my ItemWriter class is
public class StepWriter implements ItemWriter<List<StepNode>> {
#Override
public void write(List<? extends List<StepNode>> stepNodeList) throws Exception {
for (List<StepNode> list : stepNodeList) {
for (StepNode stepNode : list) {
//write to database
}
}
}
}
Error message:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘stepWriter' defined in class path resource [spring-batch-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'compreparedstatement.StepWriter' to required type 'org.springframework.batch.item.database.ItemPreparedStatementSetter' for property 'ItemPreparedStatementSetter'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.preparedstatement.StepWriter] to required type [org.springframework.batch.item.database.ItemPreparedStatementSetter] for property 'ItemPreparedStatementSetter': 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:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.JobRunner.main(JobRunner.java:23)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.preparedstatement.StepWriter' to required type 'org.springframework.batch.item.database.ItemPreparedStatementSetter' for property 'ItemPreparedStatementSetter'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.preparedstatement.StepWriter] to required type [org.springframework.batch.item.database.ItemPreparedStatementSetter] for property 'ItemPreparedStatementSetter': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:474)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 11 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.preparedstatement.StepWriter] to required type [org.springframework.batch.item.database.ItemPreparedStatementSetter] for property 'ItemPreparedStatementSetter': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
... 17 more

Custom LineMapper throwing exception in Spring Batch multiple files process

I am trying to implement custom Line Mapper and the following is my code.
When I run this code an exception is raising (exception also added)
In my resource files, each line's delimiter may be different. Some lines the delimiter is ',' or '|' and I want to handle in CustomLineMapper class.
job-read-files.xml
<bean id="domain" class="com.di.pos.Domain" />
<job id="readMultiFileJob" xmlns="http://www.springframework.org/schema/batch">
<step id="step1">
<tasklet>
<chunk reader="multiResourceReader" writer="flatFileItemWriter"
commit-interval="1" />
<!-- <listeners> <listener ref="customItemReaderListener" /> </listeners> -->
</tasklet>
</step>
</job>
<bean id="multiResourceReader" class="org.springframework.batch.item.file.MultiResourceItemReader">
<property name="resources" value="file:csv/inputs/domain-*.csv" />
<property name="delegate" ref="flatFileItemReader" />
</bean>
<bean id="flatFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="lineMapper">
<!-- <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">-->
<bean class="com.di.pos.CustomLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="id, domain" />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="domain" />
</bean>
</property>
</bean>
</property>
</bean>
and
CustomLineMapper.java
Here I have overwritten some methods.
public class CustomLineMapper<T> extends DefaultLineMapper<T> {
public LineTokenizer lineTokenizer;
public FieldSetMapper<Domain> fieldSetMapper;
#Override
public T mapLine(String line, int lineNumber) throws Exception {
System.out.println("======" + line);
DelimitedLineTokenizer delimitedLineTokenizer = new DelimitedLineTokenizer();
if (line.indexOf("|") == -1) {
if (line.indexOf(",") == -1) {
} else {
delimitedLineTokenizer.setDelimiter(",");
}
} else {
delimitedLineTokenizer.setDelimiter("|");
}
setLineTokenizer(delimitedLineTokenizer);
return (T) this.fieldSetMapper.mapFieldSet(this.lineTokenizer.tokenize(line));
}
public LineTokenizer getLineTokenizer() {
return lineTokenizer;
}
public void setLineTokenizer(LineTokenizer lineTokenizer) {
this.lineTokenizer = lineTokenizer;
}
public FieldSetMapper<Domain> getFieldSetMapper() {
return fieldSetMapper;
}
#Override
public void setFieldSetMapper(FieldSetMapper<T> fieldSetMapper) {
super.setFieldSetMapper(fieldSetMapper);
}
}
when I execute this code, I am getting the following exception.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': Cannot resolve reference to bean 'multiResourceReader' while setting bean property 'itemReader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multiResourceReader' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Cannot resolve reference to bean 'flatFileItemReader' while setting bean property 'delegate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flatFileItemReader' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Cannot create inner bean 'com.di.pos.CustomLineMapper#3c50507' of type [com.di.pos.CustomLineMapper] while setting bean property 'lineMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.di.pos.CustomLineMapper#3c50507' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The LineTokenizer must be set
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at com.di.pos.App.run(App.java:23)
at com.di.pos.App.main(App.java:15)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multiResourceReader' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Cannot resolve reference to bean 'flatFileItemReader' while setting bean property 'delegate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flatFileItemReader' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Cannot create inner bean 'com.di.pos.CustomLineMapper#3c50507' of type [com.di.pos.CustomLineMapper] while setting bean property 'lineMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.di.pos.CustomLineMapper#3c50507' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The LineTokenizer must be set
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 16 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flatFileItemReader' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Cannot create inner bean 'com.di.pos.CustomLineMapper#3c50507' of type [com.di.pos.CustomLineMapper] while setting bean property 'lineMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.di.pos.CustomLineMapper#3c50507' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The LineTokenizer must be set
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.di.pos.CustomLineMapper#3c50507' defined in class path resource [spring/batch/jobs/job-read-files.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The LineTokenizer must be set
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
... 36 more
Caused by: java.lang.IllegalArgumentException: The LineTokenizer must be set
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.batch.item.file.mapping.DefaultLineMapper.afterPropertiesSet(DefaultLineMapper.java:56)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)
... 39 more
Can anyone help me out? Thanks.
Try this:
#Override
public void setLineTokenizer(LineTokenizer lineTokenizer) {
super.setLineTokenizer(lineTokenizer);
this.lineTokenizer = lineTokenizer;
}
You need to set the lineTokenizer in the super class, as you have for the fieldSetMapper. In the afterPropertiesSet method of DefaultLineMapper, it is checking that it has a lineTokenizer, but it doesn't have one (not one that is accessible to the super-class). So it throws the IllegalArgumentException: 'The LineTokenizer must be set'.

Cannot convert value of type [JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory]

I have set up a JMSTemplate via JNDI like this:
<bean id="jmsTopicCancelacionTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestination" ref="cancelacionTopic" />
<property name="messageConverter" ref="oxmMessageConverter" />
<property name="destinationResolver" ref="jmsDestResolver" />
<property name="pubSubDomain" value="true" />
</bean>
<!-- look up the JMS ConnectionFactory in JNDI -->
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jms/ConnectionFactory</value>
</property>
</bean>
<bean id="requestQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jms/SchedulingRequestQueue</value>
</property>
</bean>
My web.xml:
<resource-ref>
<description>JMS Connection</description>
<res-ref-name>jms/ConnectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
However, when I try to bind the JNDI resource in my Websphere, I get the following error when starting up my application:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.jms.core.JmsTemplate com.plexus.xesac_il.server.service.decide.DecideServiceImpl.jmsTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [spring/xesac-il-appcontext-jms.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
... 116 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [spring/xesac-il-appcontext-jms.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:912)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
... 118 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:463)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:494)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:488)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1463)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 127 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)
... 133 more
It is my understanding that IBM's JmsManagedConnectionFactoryImpl should be implementing JmsTemplate or otherwise I wouldn't even have the chance to bind it through WebSphere, so what could be the problem here?
JmsTemplate is a class from the Spring framework. So the class JmsManagedConnectionFactoryImpl has nothing to do with the JmsTemplate (the JmsTemplate uses the ConnectionFactory, but not the reversed way). However, i think your problem is, that you are packaging the JMS api classes in your application. When you deploy the application in WebSphere, WAS has also the API classes in the classpath, and you have a conflict, because there are two API jars in different classloaders. So just exclude the API jars from your deployment, and the error should be gone.

Spring dependency issue - no matching editors or conversion strategy found

I have a web application which fails while deployment. I get following error:
Aug 8, 2014 7:00:21 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#2' while setting bean property 'sourceList' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#2': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'CustomLoginSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CustomLoginSuccessHandler': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.abc.xyz.ldapservices.LDAPUtil com.abc.xyz.web.CustomLoginSuccessHandler.ldapContact; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContact' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.ldap.core.LdapTemplate' for property 'ldapTemplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.ldap.core.LdapTemplate] for property 'ldapTemplate': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:589)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:661)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:241)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:198)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:183)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1783)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2807)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:822)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:213)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:208)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:70)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:48)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:586)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:148)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:114)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#2': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'CustomLoginSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CustomLoginSuccessHandler': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.abc.xyz.ldapservices.LDAPUtil com.abc.xyz.web.CustomLoginSuccessHandler.ldapContact; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContact' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.ldap.core.LdapTemplate' for property 'ldapTemplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy213 implementing org.springframework.ldap.core.LdapOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.ldap.core.LdapTemplate] for property 'ldapTemplate': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:615)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1049)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
I am loading my configuration XML's in web.xml using:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/spring/spring-security.xml
WEB-INF/spring/applicationContext-db.xml
WEB-INF/spring/applicationContext.xml
</param-value>
</context-param>
The error comes from my spring-security.xml file, which has :
<security:http auto-config="true" use-expressions="true"
access-denied-page="/auth/denied">
<security:intercept-url pattern="/auth/login"
access="permitAll" />
<security:intercept-url pattern="/main/admin"
access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/main/common"
access="hasRole('ROLE_RI')" />
<security:form-login login-page="/auth/login"
authentication-failure-url="/auth/login?error=true"
default-target-url="/main/common" authentication-success-handler-ref="CustomLoginSuccessHandler" />
<security:logout invalidate-session="true" logout-url="/auth/logout"
success-handler-ref="CustomLogoutSuccessHandler" />
</security:http>
<bean id="CustomLoginSuccessHandler"
class="com.abc.xyz.web.CustomLoginSuccessHandler">
<property name="ldapContact" ref="ldapContact"></property>
</bean>
<bean id="CustomLogoutSuccessHandler"
class="com.abc.xyz.web.CustomLogoutSuccessHandler">
</bean>
<security:authentication-manager>
<security:ldap-authentication-provider
user-search-filter="(uid={0})" user-search-base="ou=Users"
group-search-filter="(roleOccupant={0})" group-search-base="ou=Groups"
group-role-attribute="cn" role-prefix="ROLE_">
</security:ldap-authentication-provider>
</security:authentication-manager>
<security:ldap-server url="ldap://localhost:389/dc=maxcrc,dc=com"
manager-dn="cn=Manager,dc=maxcrc,dc=com" manager-password="secret" />
<security:global-method-security
secured-annotations="enabled" />
<!-- <bean id="placeHolderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="location" value="/WEB-INF/classes/ldap.properties"></property>
</bean>
<context:property-placeholder location="classpath:WEB-INF/classes/ldap.properties"/>
-->
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldap://localhost:389/dc=maxcrc,dc=com" />
<property name="userDn" value="cn=Manager,dc=maxcrc,dc=com" />
<property name="password" value="secret" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
<property name="ignorePartialResultException" value="true" />
</bean>
<bean id="ldapContact" class="com.abc.xyz.ldapservices.LDAPUtil">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
My CustomLoginSuccessHandler class is like:
public class CustomLoginSuccessHandler implements AuthenticationSuccessHandler {
/** The redirect strategy. */
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
/** The ldap contact. */
#Autowired
LDAPUtil ldapContact;
I am new to spring but i guess it is due to the bean dependencies configuration.
1. What is the sequence of spring bean dependency, does it uses
sequence of XML configuration from web.xml?
2. Suppose I refer bean A
in a XML file, which is defined below where it is refered, will it
create any problem?
EDIT
My LDAPUtil class is like:
private LdapOperations ldapTemplate;
public void setLdapTemplate(LdapTemplate ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}
The error gives useful elements. The cause (last error in chain) is (stripped down string) :
Error creating bean with name 'ldapContact' ... Failed to convert property value of type '$Proxy213 implementing ... LdapOperations ...' to required type '....LdapTemplate' for property 'ldapTemplate'
You did not show LdapUtil source, but from CustomSuccessHandler and the error, I presume it contains somewhere :
#Autowired
LdapTemplate ldapTemplate;
The error indicates that there is an AOP proxying mechanisme around the ldapTemplatebean.
It is not a problem, except that by default Spring AOP uses JDK proxies, and a proxy implements all interfaces, but does not extends the original class. You should be able to fix the error by referencing ldapTemplate through an interface :
#Autowired
LdapOperations ldapTemplate;
Alternatively, you can ask Spring to use cglib proxies, that do extend original class by using <aop:config proxy-target-class = "true"> in xml file (or <aop:aspectj-autoproxy proxy-target-class="true"/> if you are using annotations). But that requires cglib jars to be on the path, and as you can use interfaces, I advice you to use first solution.
EDIT :
Your edited post shows how you load ldapTemplate in LdapUtil. You load it as a class, when you should use the interface that way :
private LdapOperations ldapTemplate;
public void setLdapTemplate(LdapOperations ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}

Categories

Resources