• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

MailSender error

 
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I have this method on my Controller for send email

XML config


This works fine and the email is send

The problem occurs when i create a service class and pass everything there.

The service Class



and i change my Controller like this


Then i cannot run the application because of this error



after some Hours i have removed @Autowire from the Service Class and i have try it again .Application loads correclty not like before but i have nullpointer Exception


I use Spring 3.2.3
and my pom.xml


Is this a problem of SimpleMailMessage mail ?
Why with Autowire does not workk if i move everything on My service Class.
I have also read spring docs and other but with no luck.
Any Help
thanks
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring is complaining about not having any MailSender to inject. How are you injecting it in your controller for your first case? The behaviour specified below is fully expected, if you remove the @Autowire dependency, Spring won't try to inject the instance, so the method will fail with a NullPointer when trying to send an email.
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aritz Maeztu wrote:Spring is complaining about not having any MailSender to inject. How are you injecting it in your controller for your first case? The behaviour specified below is fully expected, if you remove the @Autowire dependency, Spring won't try to inject the instance, so the method will fail with a NullPointer when trying to send an email.


yes you are rigth but if i add @Autowire i will get couldn't create bean. I have the error above to see. What else i can do?
 
reply
    Bookmark Topic Watch Topic
  • New Topic