Announcement Announcement Module
Collapse
No announcement yet.
Configuring mailSender throws PropertyAccessExceptionsException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring mailSender throws PropertyAccessExceptionsException

    Hello,

    I was trying to configure a mailSender in my application using the following piece of code:


    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
    <property name="session" ref="mailSession"/>
    </bean>

    <bean id="mailSession" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:comp/env/mail/Session</value>
    </property>
    </bean>


    When I started my application the following exception was thrown:

    2007-02-26 13:39:38,943 ERROR [localhost].[/sponsoring] - Exception sending context initialized event to listener instance of class org.spri
    ngframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mailSender' defined in class path resource [spring/s
    ponsoringWebApplicationContext.xml]: Error setting property values; nested exception is PropertyAccessExceptionsException (1 errors)
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.mail.Session] to required type [javax.mail.
    Session] for property 'session'
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:951)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:692)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:572)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:737)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:764)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:753)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1057)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:857)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:378)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:283)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:139)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:252)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:190)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3692)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4127)
    .......
    .......

    I have the same configuration in another webapp and that application does get initialized properly.

    Any suggestions about what is wrong and how I can fix this?

    I'm using Spring 1.2.8 for an application running on Tomcat 5.5.12 in JVM 1.5.0_07.

    With kind regards,
    Marco

  • #2
    Code:
    Failed to convert property value of type [javax.mail.Session] to required type [javax.mail.Session]
    This kind of error message normally points to the classpath. Do you have duplicate copies of javax.mail.Session in different classloaders (e.g. one in the server and one in the app)?

    Comment

    Working...
    X