You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Michael Bauroth <Mi...@falcom.de> on 2006/08/04 00:59:03 UTC

Spring and IoFilterMapping

Hi,

can you tell me, what's wrong with this code?

<bean class="org.apache.mina.integration.spring.IoFilterMapping">
   <constructor-arg value="abc" />
   <constructor-arg>
     <bean class="org.apache.mina.filter.LoggingFilter"/>
   </constructor-arg>
</bean>

When I use instead:

<bean class="org.apache.mina.filter.LoggingFilter" />

all works fine. When I check the code of class IoFilterMapping, the 
first approach should work?

Regards
Michael

Re: Spring and IoFilterMapping

Posted by Michael Bauroth <Mi...@falcom.de>.
Hi Niklas,

congratulations!!! The fix solved the problem completely :)

Just a last question (only for the correct understanding):

When I leave the original behaviour for the acceptor threadpool, the 
PooledByteBufferAllocator will be used, right? So when this is the case, 
how can I switch to the SimpleByteBufferAllocator instead?

Regards
Michael

Niklas Therning wrote:

> I just checked in a fix for this. It should now be possible to mix
> IoFilter and IoFilterMapping objects in the <list> in your Spring file.
> Let me know if this fix solves your problem.
> 
> /Niklas


Re: Spring and IoFilterMapping

Posted by Niklas Therning <ni...@trillian.se>.
I just checked in a fix for this. It should now be possible to mix
IoFilter and IoFilterMapping objects in the <list> in your Spring file.
Let me know if this fix solves your problem.

/Niklas

Michael Bauroth wrote:
> Here is the exception:
>
> Exception in thread "main"
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'filterChainBuilder' defined in file
> [/opt/tracker2/./etc/jmxServerContext.xml]: Error setting property
> values; nested exception is PropertyAccessExceptionsException (1 errors)
> Caused by: PropertyAccessExceptionsException (1 errors)
> org.springframework.beans.TypeMismatchException: Failed to convert
> property value of type [java.util.ArrayList] to required type
> [org.apache.mina.common.IoFilter[]] for property 'filters'; nested
> exception is java.lang.IllegalArgumentException: No matching editors
> or conversion strategy found
> Caused by: java.lang.IllegalArgumentException: No matching editors or
> conversion strategy found
>         at
> org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:209)
>
>         at
> org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:93)
>
>         at
> org.springframework.beans.PropertyTypeConverter.convertToTypedArray(PropertyTypeConverter.java:264)
>
>         at
> org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:182)
>
>         at
> org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:108)
>
>         at
> org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:723)
>
>         at
> org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:575)
>
>         at
> org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
>
>         at
> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:68)
>
>         at
> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
>
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:809)
>
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:589)
>
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:389)
>
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:256)
>
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
>
>         at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:253)
>
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:332)
>
>         at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)
>
>         at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)
>
>
>
> And here is the complete filterchain:
>
> <bean id="filterChainBuilder"
> class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean">
>
>   <property name="filters">
>     <list>
>       <bean class="org.apache.mina.filter.thread.ThreadPoolFilter">
>         <constructor-arg>
>           <bean
> class="org.apache.mina.filter.thread.LeaderFollowersThreadPool">
>             <property name="threadNamePrefix" value="IoWorker"/>
>             <property name="maximumPoolSize" value="16"/>
>             <property name="keepAliveTime" value="60000"/>
>           </bean>
>         </constructor-arg>
>       </bean>
>            
>       <bean class="org.apache.mina.integration.spring.IoFilterMapping">
>         <property name="name" value="LOGGING_FILTER" />
>         <property name="filter">
>           <bean class="org.apache.mina.filter.LoggingFilter"/>
>         </property>
>       </bean>
>
>     </list>
>   </property>
> </bean>
>
> The same happens also, when I use only the part:
>
> <bean id="filterChainBuilder"
> class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean">
>
>   <property name="filters">
>     <list>
>            
>       <bean class="org.apache.mina.integration.spring.IoFilterMapping">
>         <property name="name" value="LOGGING_FILTER" />
>         <property name="filter">
>           <bean class="org.apache.mina.filter.LoggingFilter"/>
>         </property>
>       </bean>
>
>     </list>
>   </property>
> </bean>
>
> If you need more of the config file, I can attach the whole one in the
> next mail.
>
> Regards
> Michael
>
>
> Niklas Therning wrote:
>> Michael Bauroth wrote:
>>
>>> Hi,
>>>
>>> can you tell me, what's wrong with this code?
>>>
>>> <bean class="org.apache.mina.integration.spring.IoFilterMapping">
>>>  <constructor-arg value="abc" />
>>>  <constructor-arg>
>>>    <bean class="org.apache.mina.filter.LoggingFilter"/>
>>>  </constructor-arg>
>>> </bean>
>>>
>>> When I use instead:
>>>
>>> <bean class="org.apache.mina.filter.LoggingFilter" />
>>>
>>> all works fine. When I check the code of class IoFilterMapping, the
>>> first approach should work?
>>>
>>
>> What happens with the first? Do you get an exception? If that's the case
>> please post it here. I think the first should work as long as you don't
>> mix the two approaches. You must either use explicit IoFilterMappings
>> for all your filters set on a DefaultIoFilterChainBuilderFactoryBean or
>> use the simpler for all. You can't mix them.
>>
>> You could try to use:
>>
>> <bean class="org.apache.mina.integration.spring.IoFilterMapping">
>>   <property name="name" value="abc" />
>>   <property name="filter">
>>     <bean class="org.apache.mina.filter.LoggingFilter"/>
>>   </property>
>> </bean>
>>
>> instead. I've had some problems with Spring and constructor-arg before
>> where Spring couldn't find a matching constructor or picked the wrong
>> one. Though I don't think that's the case here.
>>
>> It might help if I get to see more of your Spring file.
>>
>


Re: Spring and IoFilterMapping

Posted by Michael Bauroth <Mi...@falcom.de>.
Here is the exception:

Exception in thread "main" 
org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 'filterChainBuilder' defined in file 
[/opt/tracker2/./etc/jmxServerContext.xml]: Error setting property 
values; nested exception is PropertyAccessExceptionsException (1 errors)
Caused by: PropertyAccessExceptionsException (1 errors)
org.springframework.beans.TypeMismatchException: Failed to convert 
property value of type [java.util.ArrayList] to required type 
[org.apache.mina.common.IoFilter[]] for property 'filters'; nested 
exception is java.lang.IllegalArgumentException: No matching editors or 
conversion strategy found
Caused by: java.lang.IllegalArgumentException: No matching editors or 
conversion strategy found
         at 
org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:209)
         at 
org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:93)
         at 
org.springframework.beans.PropertyTypeConverter.convertToTypedArray(PropertyTypeConverter.java:264)
         at 
org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:182)
         at 
org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:108)
         at 
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:723)
         at 
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:575)
         at 
org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
         at 
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:68)
         at 
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:809)
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:589)
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:389)
         at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:256)
         at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
         at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:253)
         at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:332)
         at 
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)
         at 
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)


And here is the complete filterchain:

<bean id="filterChainBuilder" 
class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean">
   <property name="filters">
     <list>
       <bean class="org.apache.mina.filter.thread.ThreadPoolFilter">
         <constructor-arg>
           <bean 
class="org.apache.mina.filter.thread.LeaderFollowersThreadPool">
             <property name="threadNamePrefix" value="IoWorker"/>
             <property name="maximumPoolSize" value="16"/>
             <property name="keepAliveTime" value="60000"/>
           </bean>
         </constructor-arg>
       </bean>
			
       <bean class="org.apache.mina.integration.spring.IoFilterMapping">
         <property name="name" value="LOGGING_FILTER" />
         <property name="filter">
           <bean class="org.apache.mina.filter.LoggingFilter"/>
         </property>
       </bean>

     </list>
   </property>
</bean>

The same happens also, when I use only the part:

<bean id="filterChainBuilder" 
class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean">
   <property name="filters">
     <list>
			
       <bean class="org.apache.mina.integration.spring.IoFilterMapping">
         <property name="name" value="LOGGING_FILTER" />
         <property name="filter">
           <bean class="org.apache.mina.filter.LoggingFilter"/>
         </property>
       </bean>

     </list>
   </property>
</bean>

If you need more of the config file, I can attach the whole one in the 
next mail.

Regards
Michael


Niklas Therning wrote:
> Michael Bauroth wrote:
> 
>>Hi,
>>
>>can you tell me, what's wrong with this code?
>>
>><bean class="org.apache.mina.integration.spring.IoFilterMapping">
>>  <constructor-arg value="abc" />
>>  <constructor-arg>
>>    <bean class="org.apache.mina.filter.LoggingFilter"/>
>>  </constructor-arg>
>></bean>
>>
>>When I use instead:
>>
>><bean class="org.apache.mina.filter.LoggingFilter" />
>>
>>all works fine. When I check the code of class IoFilterMapping, the
>>first approach should work?
>>
> 
> What happens with the first? Do you get an exception? If that's the case
> please post it here. I think the first should work as long as you don't
> mix the two approaches. You must either use explicit IoFilterMappings
> for all your filters set on a DefaultIoFilterChainBuilderFactoryBean or
> use the simpler for all. You can't mix them.
> 
> You could try to use:
> 
> <bean class="org.apache.mina.integration.spring.IoFilterMapping">
>   <property name="name" value="abc" />
>   <property name="filter">
>     <bean class="org.apache.mina.filter.LoggingFilter"/>
>   </property>
> </bean>
> 
> instead. I've had some problems with Spring and constructor-arg before
> where Spring couldn't find a matching constructor or picked the wrong
> one. Though I don't think that's the case here.
> 
> It might help if I get to see more of your Spring file.
> 

Re: Spring and IoFilterMapping

Posted by Niklas Therning <ni...@trillian.se>.
Michael Bauroth wrote:
> Hi,
>
> can you tell me, what's wrong with this code?
>
> <bean class="org.apache.mina.integration.spring.IoFilterMapping">
>   <constructor-arg value="abc" />
>   <constructor-arg>
>     <bean class="org.apache.mina.filter.LoggingFilter"/>
>   </constructor-arg>
> </bean>
>
> When I use instead:
>
> <bean class="org.apache.mina.filter.LoggingFilter" />
>
> all works fine. When I check the code of class IoFilterMapping, the
> first approach should work?
>
What happens with the first? Do you get an exception? If that's the case
please post it here. I think the first should work as long as you don't
mix the two approaches. You must either use explicit IoFilterMappings
for all your filters set on a DefaultIoFilterChainBuilderFactoryBean or
use the simpler for all. You can't mix them.

You could try to use:

<bean class="org.apache.mina.integration.spring.IoFilterMapping">
  <property name="name" value="abc" />
  <property name="filter">
    <bean class="org.apache.mina.filter.LoggingFilter"/>
  </property>
</bean>

instead. I've had some problems with Spring and constructor-arg before
where Spring couldn't find a matching constructor or picked the wrong
one. Though I don't think that's the case here.

It might help if I get to see more of your Spring file.

-- 
Niklas Therning
Software Architect
www.spamdrain.net