1 Reply Latest reply on Sep 29, 2010 8:50 PM by Mark Wen

    MailEngine cannot be wired

    Mark Wen Newbie

      Hi everyone,

       

      I am asking help for deploying my spring application in JBoss 5.1.

       

      I have a MailEngine class like the one below (if you feel familiar, yes - it's from Appfuse):

       

      public class MailEngine {
          private final Log log = LogFactory.getLog(MailEngine.class);
          private MailSender mailSender;
          private VelocityEngine velocityEngine;
          private String defaultFrom;

       

          public void setMailSender(MailSender mailSender) {
              this.mailSender = mailSender;
          }

       

          public MailSender getMailSender() {
              return mailSender;
          }
      ...
      }

       

      And there are some simple configuratinon in spring context:

       

          <bean id="mailEngine" class="com.mycompany.service.MailEngine">
              <property name="mailSender" ref="mailSender"/>
              <property name="velocityEngine" ref="velocityEngine"/>
              <property name="from" value="${mail.default.from}"/>
          </bean>

       

          <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
              <property name="host" value="${mail.host}"/>
              <!-- Uncomment if you need to authenticate with your SMTP Server -->
              <!--property name="username" value="${mail.username}"/>
              <property name="password" value="${mail.password}"/>
              <property name="javaMailProperties">
                  <value>
                      mail.smtp.auth=true
                  </value>
              </property-->
          </bean>

       

      When I started the application in JBoss 5.1 Server, it triggered the following error:

       

      Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.mail.javamail.JavaMailSenderImpl' to required type 'org.springframew
      ork.mail.MailSender' for property 'mailSender'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.mail.javamail.JavaMailSenderImpl] to required typ
      e [org.springframework.mail.MailSender] for property 'mailSender': no matching editors or conversion strategy found
              at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:462)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1351)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1310)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
              ... 81 more
      Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.mail.javamail.JavaMailSenderImpl] to required type [org.springframework.mail.MailSender] for property 'mai
      lSender': no matching editors or conversion strategy found
              at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:289)
              at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154)
              at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452)
              ... 85 more

       


      I've googled several hours, and didn't find any useful information. Anybody experienced in Spring and JBoss can help me?

       

      Thanks a lot.

       

      Mark