Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

MailSender error

 
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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?
 
Seriously? That's what you're going with? I prefer this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic