Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:55:17+00:00 2026-06-12T23:55:17+00:00

I configured JavaMail with Spring framework using JavaMailSenderImpl in my application.Actually I tried to

  • 0

I configured JavaMail with Spring framework using JavaMailSenderImpl in my application.Actually I tried to load mailing properties from database and done little bit changes at spring config.xml file.
But i got error

“Initialization of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert
property value of type [com.core.springexamples.UCMSMailImpl] to
required type [org.springframework.mail.MailSender] for property
‘mailSender’; nested exception is java.lang.IllegalArgumentException:
Cannot convert value of type [com.core.springexamples.UCMSMailImpl] to
required type [org.springframework.mail.MailSender] for property
‘mailSender’: no matching editors or conversion strategy found”

whatever changes are implemented in my application,those are mentioned in below.

Step 1:

<bean id="javaMailImpl" class="org.springframework.mail.javamail.JavaMailSenderImpl"></bean>

Step 2:-

<bean id="mailSender" class="com.core.springexamples.UCMSMailImpl" scope="prototype" init-method="configuredProperties">
    <property name="javaMailImpl" ref="javaMailImpl"></property>
</bean>

com.core.springexamples.UCMSMailImpl:-

public class UCMSMailImpl {
    private JavaMailSenderImpl javaMailImpl;
    private ConfigDAO configDAO;

    public  void configuredProperties(){
        System.out.println("UCMSMailImpl::configuredProperties");
        Properties props=new Properties();
    String[] mildata=configDAO.getMailingPropData();
        props.put("mail.smtp.auth", mildata[0]);
        props.put("mail.smtp.starttls.enable", mildata[2]);
        props.put("mail.smtp.host", mildata[3]);
        props.put("mail.smtp.port", mildata[4]);
        props.put("mail.smtp.host", mildata[5]);
        props.put("username", mildata[6]);
        props.put("password",mildata[7]);
        getJavaMailImpl().setJavaMailProperties(props);

    }
    public JavaMailSenderImpl getJavaMailImpl() {
        return javaMailImpl;
    }
    public void setJavaMailImpl(JavaMailSenderImpl javaMailImpl) {
        this.javaMailImpl = javaMailImpl;
    }
    public void setConfigDAO(ConfigDAO configDAO){
    this.configDAO=configDAO;
    }
    public ConfigDAO getConfigDAO(){
    return configDAO;
    }

Step 3:-I am trying send the mail from MailSender.send using UCMSMailImpl java class.I refered the UCMSMailImpl bean.

<bean id="sendMail" class="com.core.springexamples.JavaMailing">
    <property name="mailSender" ref="mailSender"></property>

</bean>


public class JavaMailing {
    private MailSender mailSender;


    public void sendMail(String from,String to,String text,String subject){
        SimpleMailMessage message = new SimpleMailMessage();
                message.setFrom(from);
        message.setTo(to);
        message.setSubject(subject);
        message.setText(text);
        mailSender.send(message);   

    }

    /**
     * @return the mailSender
     */
    public MailSender getMailSender() {
        return mailSender;
    }

    /**
     * @param mailSender the mailSender to set
     */
    public void setMailSender(MailSender mailSender) {
        this.mailSender = mailSender;
    }

Step 4:- I trying to test the sendMail bean

ApplicationContext context =new ClassPathXmlApplicationContext("applicationContext-mail.xml");
    JavaMailing m=(JavaMailing)context.getBean("sendMail");
   m.sendMail("john.ch@gmail.com", "john.c@gmail.com", "TEST MAIL", "TEST MAIL");

But i got exception is TypeMismatchException: Failed to convert property value of type [com.core.springexamples.UCMSMailImpl] to required type [org.springframework.mail.MailSender] for property

Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:55:18+00:00Added an answer on June 12, 2026 at 11:55 pm

    You cannot assign a class to an interface, if it doesn’t implement the interface. UCMSMailImpl does not implement MailSender. Keep the rest as it is and change your UCMSMailImpl like this:

    public class UCMSMailImpl implements MailSender {
    
        private JavaMailSenderImpl javaMailImpl;
        private ConfigDAO configDAO;
    
        // do your property initialization
        // ...
    
        // implement interface methods
    
        void send(SimpleMailMessage simpleMessage) throws MailException {
            this.javaMailImpl.send(simpleMessage);
        }
    
        void send(SimpleMailMessage[] simpleMessages) throws MailException {
            this.javaMailImpl.send(simpleMEssages);
        }
    

    }

    If you cannot change UCMSMailImpl, extend it:

    public class MyUCMSMailImpl extends UCMSMailImpl implements MailSender {
    
        void send(SimpleMailMessage simpleMessage) throws MailException {
            this.getgetJavaMailImpl().send(simpleMessage);
        }
    
        void send(SimpleMailMessage[] simpleMessages) throws MailException {
            this.getgetJavaMailImpl().send(simpleMEssages);
        }
    
    }
    

    and change your configuration:

    <bean id="mailSender" class="your.package.MyUCMSMailImpl" scope="prototype" init-method="configuredProperties">
        <property name="javaMailImpl" ref="javaMailImpl"></property>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I configured my web application like this link http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch17s04.html My context <bean id=freemarkerConfig class=org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer>
I configured a new Play Framework application to connect to an existing Sybase database,
I configured my Emacs for code completion and other help using this link (from
I configured a default locale, and set up a text.properties + text_de.properties. <application> <locale-config>
I've configured my SSIS configuration to load from an XML file. When I run
I configured and developped an intranet application that combines: spring 3.0.5 (including security) +
I configured Second Level Cache using Ehcache in hibernate.cfg.xml ,ehcache.xml.And setting the cache-usage property
I configured GWT 2.4.0 + Hibernate 4.x I used Using Data Transfer Objects (DTO)
I configured every thing and tried to run the build i am getting the
BasicDataSource configured in spring Weblogic datasource which implementation is better in terms of Stability

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.