Hi all,
I am new to spring.I am doing mail application in spring and i want to do console application only.
here is the code of applicationContext.xml
And this is the application OrderSend.javaCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host"><value>mail.2xprime.com</value></property> </bean> <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from"><value>sureshc@2xprime.com</value></property> <property name="subject"><value>TEst Mail</value></property> </bean> <bean id="orderSend" class="com.prime.maileg.OrderSend"> <property name="mailSender"><ref bean="mailSender"/></property> <property name="message"><ref bean="mailMessage"/></property> </bean> </beans>
and my folder structure of the application is:Code:public class OrderSend { static private MailSender mailSender; static private SimpleMailMessage message; public void setMailSender(MailSender mailSender) { OrderSend.mailSender = mailSender; } public void setMessage(SimpleMailMessage message) { OrderSend.message = message; } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //Resource res = new ClassPathResource("application-context.xml"); //BeanFactory factory = new XmlBeanFactory(res); SimpleMailMessage msg = new SimpleMailMessage(OrderSend.message); msg.setTo("sureshc@2xprime.com"); msg.setText("test mail"); try{ mailSender.send(msg); } catch(MailException ex) { //log it and go on System.err.println(ex.getMessage()); } } }
<dir>com.prime.maileg(Package)
OrderSend.java
lib
spring.jar
applicationContext.xml
My application is compiling fine.but while running it is giving the following error:
Pleaese help me ...Code:Exception in thread "main" java.lang.IllegalArgumentException: The 'original' message argument cannot be null at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.mail.SimpleMailMessage.<init>(SimpleMailMessage.java:73) at com.prime.maileg.OrderSend.main(OrderSend.java:29)
Thanks in advance
Suresh


Reply With Quote
Since Spring makes use of a number of other libraries itself, it needs access to them at runtime to function properly. You provide access to these libraries by including them on your classpath. If you download the '-with-dependencies' distribution of Spring (from here: 