Hello All,
I am a new to spring framework.
I want to send an email to user for alert purpose.
I have want to expose this as a cxf web service.
After creating classes from WSDL2Java plug in i have implemented necessary methods in my NotificationServiceImpl class.
Following is my XML configuration.
XML:
===
<bean class="com.pmc.ws.notificationservice.NotificationServiceImpl">
<property name="mailSender" ref="mailSender"/>
<property name="messageTemplate" ref="messageTemplate"/>
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="10.60.10.210"/>
<!-- Uncomment if you need to authenticate with your SMTP Server -->
<property name="username" value="Live.Server@abc.in"/>
<property name="password" value="abc123"/>
<property name="port" value="25"/>
<property name="javaMailProperties">
<value>
mail.smtp.auth=true
</value>
</property>
</bean>
<bean id="messageTemplate" class="org.springframework.mail.SimpleMailMessage" scope="prototype">
<property name="from" value="Live.Server@abc.in"/>
</bean>
Following is my NotificationServiceImpl class
=============================
/**
* Please modify this class to meet your needs
* This class is not complete
*/
package com.pmc.ws.notificationservice;
import java.util.logging.Logger;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
/**
* This class was generated by Progress FUSE Services Framework 2.2.x-fuse-SNAPSHOT
* Tue Jul 20 10:22:34 IST 2010
* Generated source version: 2.2.x-fuse-SNAPSHOT
*
*/
@javax.jws.WebService(
serviceName = "NotificationService",
portName = "NotificationServiceSOAP",
targetNamespace = "http://www.ws.pmc.com/NotificationService/",
endpointInterface = "com.pmc.ws.notificationservice.NotificationService")
public class NotificationServiceImpl implements NotificationService {
private static final Logger LOG = Logger.getLogger(NotificationServiceImpl.class.getName());
private MailSender mailSender = null;
private SimpleMailMessage messageTemplate = null;
public MailSender getMailSender() {
return mailSender;
}
public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;
}
public SimpleMailMessage getMessageTemplate() {
return messageTemplate;
}
public void setMessageTemplate(SimpleMailMessage messageTemplate) {
this.messageTemplate = messageTemplate;
}
public void prepareAndSendEmail (){
messageTemplate.setTo("chirag.borkar@abc.in");
messageTemplate.setSubject("Testing Notification Service");
messageTemplate.setText("TAAAAADDDDDDDDDd");
getMailSender().send(messageTemplate);
}
/* (non-Javadoc)
* @see com.pmc.ws.notificationservice.NotificationService#notifyByEmail(com.pmc.ws.notificationservice.GenericRequest genericRequest ,)com.pmc.ws.notificationservice.EmailMessage emailMessage ,)java.lang.String messageType ,)java.util.List<com.pmc.ws.notificationservice.PlaceHolder> placeHolder )*
*/
public com.pmc.ws.notificationservice.GenericResponse notifyByEmail(com.pmc.ws.notificationservice.GenericRequest genericRequest,com.pmc.ws.notificationservice.EmailMessage emailMessage,java.lang.String messageType,java.util.List<com.pmc.ws.notificationservice.PlaceHolder> placeHolder) {
LOG.info("Executing operation notifyByEmail");
System.out.println(genericRequest);
System.out.println(emailMessage);
System.out.println(messageType);
System.out.println(placeHolder);
try {
com.pmc.ws.notificationservice.GenericResponse _return = new GenericResponse();
_return.setResponseCode(1);
_return.setResponseMessage("testing");
_return.setResponseStatus("Seding
test email");
prepareAndSendEmail();
return _return;
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
}
When I deploy it i am getting following exception.
================================
<exception-info>
<nesting-level>1</nesting-level>
<msg-loc-info>
<loc-token />
<loc-message>Error creating bean with name 'org.apache.servicemix.cxfse.CxfSeEndpoint#0' defined in file [C:\apache-servicemix-4.2\data\jbi\Notification-sa\sus\Notification-se-su\xbean.xml]: Cannot create inner bean 'com.pmc.ws.notificationservice.NotificationServiceImpl#0' of type [com.pmc.ws.notificationservice.NotificationServiceImpl] while setting bean property 'pojo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.pmc.ws.notificationservice.NotificationServiceImpl#0' defined in file [C:\apache-servicemix-4.2\data\jbi\Notification-sa\sus\Notification-se-su\xbean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mailSender' of bean class [com.pmc.ws.notificationservice.NotificationServiceImpl]: Bean property 'mailSender' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?</loc-message>
<stack-trace><![CDATA[org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.servicemix.cxfse.CxfSeEndpoint#0' defined in file [C:\apache-servicemix-4.2\data\jbi\Notification-sa\sus\Notification-se-su\xbean.xml]: Cannot create inner bean 'com.pmc.ws.notificationservice.NotificationServiceImpl#0' of type [com.pmc.ws.notificationservice.NotificationServiceImpl] while setting bean property 'pojo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.pmc.ws.notificationservice.NotificationServiceImpl#0' defined in file [C:\apache-servicemix-4.2\data\jbi\Notification-sa\sus\Notification-se-su\xbean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mailSender' of bean class [com.pmc.ws.notificationservice.NotificationServiceImpl]: Bean property 'mailSender' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:117)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:87)
at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
at org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
at org.apache.servicemix.jbi.deployer.artifacts.ServiceUnitImpl.deploy(ServiceUnitImpl.java:104)
at org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.deploySUs(ServiceAssemblyInstaller.java:207)
at org.apache.servicemix.jbi.deployer.impl.ServiceAssemblyInstaller.install(ServiceAssemblyInstaller.java:85)
at org.apache.servicemix.jbi.deployer.impl.Deployer.onBundleStarted(Deployer.java:352)
at org.apache.servicemix.jbi.deployer.impl.Deployer.bundleChanged(Deployer.java:282)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:919)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1350)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1301)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:362)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:272)
at org.apache.felix.karaf.shell.osgi.InstallBundle.doExecute(InstallBundle.java:54)
at org.apache.felix.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:41)
at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
at org.apache.felix.karaf.shell.console.jline.Console.run(Console.java:181)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.pmc.ws.notificationservice.NotificationServiceImpl#0' defined in file [C:\apache-servicemix-4.2\data\jbi\Notification-sa\sus\Notification-se-su\xbean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mailSender' of bean class [com.pmc.ws.notificationservice.NotificationServiceImpl]: Bean property 'mailSender' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219)
... 42 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'mailSender' of bean class [com.pmc.ws.notificationservice.NotificationServiceImpl]: Bean property 'mailSender' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:801)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
... 48 more
Any Help will be appreciated.
Thanks & Regards,
Chirag Borkar