You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Christoph Walcher <mi...@spamgourmet.com> on 2007/05/02 14:34:25 UTC

Problems with SocketAcceptor usage from Spring

SVN revision 534322 breaks my Spring configuration on JDK 1.5. My
problem is quite similar to the problem posted by Vic Ganora but the
fix applied did not work for me.
The problem seems to occur because the beanInfo for SocketAcceptor
doesn't report the setter for the localAddress property because
getLocalAddress returns an instance of INetSocketAddress while the
related setter accepts SocketAddress instances.
IMHO it would be more clear to use SocketAddress in both cases and
furthermore it would solve my problem.


Exception extract:
Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'org.apache.mina.transport.socket.nio.SocketAcceptor'
defined in file [xxxxx.xml]: Error setting property values; nested
exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'localAddress' of bean class
[org.apache.mina.transport.socket.nio.SocketAcceptor]: Bean property
'localAddress' is not writable or has an invalid setter method. Does
the parameter type of the setter match the return type of the getter?

Re: Problems with SocketAcceptor usage from Spring

Posted by Trustin Lee <tr...@gmail.com>.
On 5/3/07, Christoph Walcher <ch...@gmail.com> wrote:
> Hi,
>
> i just switched to Spring version 2.0.4 - now the exception looks a
> little bit different:

Yep.  It looks like Spring team fixed their issue.


> org.springframework.beans.TypeMismatchException: Failed to convert
> property value of type [java.lang.String] to required type

You need to specify the property editor for InetSocketAddress.  You
could add the following element:

  <!-- This makes it possible to specify java.net.SocketAddress values
    (e.g. :1234 below) as Strings.
    They will be converted into java.net.InetSocketAddress objects by
Spring.  -->
  <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
      <map>
        <entry key="java.net.SocketAddress">
          <bean
class="org.apache.mina.integration.spring.InetSocketAddressEditor" />
        </entry>
      </map>
    </property>
  </bean>

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Problems with SocketAcceptor usage from Spring

Posted by Christoph Walcher <ch...@gmail.com>.
Hi,

i just switched to Spring version 2.0.4 - now the exception looks a
little bit different:

org.springframework.beans.TypeMismatchException: Failed to convert
property value of type [java.lang.String] to required type
[java.net.InetSocketAddress] for property 'localAddress'; nested
exception is java.lang.IllegalArgumentException: Method must not be
null
	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:385)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1085)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:835)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)

After doing some debugging the cause is that Spring's
BeanWrapperImpl.convertForProperty tries to acquire a
PropertyDescriptor via
cachedIntrospectionResults.getPropertyDescriptor method but this
PropertyDescritor instance has write method set to null for
localAddress Property which causes the later exception. I'm using jdk
1.5...

Christoph

On 5/2/07, Trustin Lee <tr...@gmail.com> wrote:
> On 5/2/07, Christoph Walcher <mi...@spamgourmet.com> wrote:
> > SVN revision 534322 breaks my Spring configuration on JDK 1.5. My
> > problem is quite similar to the problem posted by Vic Ganora but the
> > fix applied did not work for me.
> > The problem seems to occur because the beanInfo for SocketAcceptor
> > doesn't report the setter for the localAddress property because
> > getLocalAddress returns an instance of INetSocketAddress while the
> > related setter accepts SocketAddress instances.
> > IMHO it would be more clear to use SocketAddress in both cases and
> > furthermore it would solve my problem.
> >
> >
> > Exception extract:
> > Exception in thread "main"
> > org.springframework.beans.factory.BeanCreationException: Error creating
> > bean with name 'org.apache.mina.transport.socket.nio.SocketAcceptor'
> > defined in file [xxxxx.xml]: Error setting property values; nested
> > exception is org.springframework.beans.NotWritablePropertyException:
> > Invalid property 'localAddress' of bean class
> > [org.apache.mina.transport.socket.nio.SocketAcceptor]: Bean property
> > 'localAddress' is not writable or has an invalid setter method. Does
> > the parameter type of the setter match the return type of the getter?
>
> Which version of Spring framework are you using?  Did you try with the
> latest version of Spring?
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Re: Problems with SocketAcceptor usage from Spring

Posted by Trustin Lee <tr...@gmail.com>.
On 5/2/07, Christoph Walcher <mi...@spamgourmet.com> wrote:
> SVN revision 534322 breaks my Spring configuration on JDK 1.5. My
> problem is quite similar to the problem posted by Vic Ganora but the
> fix applied did not work for me.
> The problem seems to occur because the beanInfo for SocketAcceptor
> doesn't report the setter for the localAddress property because
> getLocalAddress returns an instance of INetSocketAddress while the
> related setter accepts SocketAddress instances.
> IMHO it would be more clear to use SocketAddress in both cases and
> furthermore it would solve my problem.
>
>
> Exception extract:
> Exception in thread "main"
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'org.apache.mina.transport.socket.nio.SocketAcceptor'
> defined in file [xxxxx.xml]: Error setting property values; nested
> exception is org.springframework.beans.NotWritablePropertyException:
> Invalid property 'localAddress' of bean class
> [org.apache.mina.transport.socket.nio.SocketAcceptor]: Bean property
> 'localAddress' is not writable or has an invalid setter method. Does
> the parameter type of the setter match the return type of the getter?

Which version of Spring framework are you using?  Did you try with the
latest version of Spring?

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6