AnsweredAssumed Answered

Error al enviar email (mail.port)

Question asked by magarcia_sm on Apr 29, 2016
Latest reply on May 2, 2016 by magarcia_sm
Hola,

Os comento, estoy intentado enviar emails por código java, pero me está dando el siguiente error.


GRAVE: Exception sending context initialized event to listener instance of class org.alfresco.web.app.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailService' defined in file [D:\WSIntellJ\smveritascontratos\target\smveritascontratos-war\WEB-INF\classes\alfresco\extension\service-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'port'; nested exception is java.lang.NumberFormatException: For input string: "${mail.port}"
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'port'; nested exception is java.lang.NumberFormatException: For input string: "${mail.port}"
   at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:467)
   at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
   at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
   … 21 more
Caused by: java.lang.NumberFormatException: For input string: "${mail.port}"
   at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
   at java.lang.Integer.parseInt(Integer.java:569)
   at java.lang.Integer.valueOf(Integer.java:766)
   at org.springframework.util.NumberUtils.parseNumber(NumberUtils.java:155)
   at org.springframework.beans.propertyeditors.CustomNumberEditor.setAsText(CustomNumberEditor.java:116)
   at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:416)
   at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:388)
   at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:157)
   at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
   … 27 more





El bean lo tengo configura en el service-context.xml de la siguiente manera.


<!–                        –>
   <!– MAIL SERVICE           –>
   <!–                        –>
    <!–Modificar la declaración del mailService en tomcat/webapps/inicial/WEB-INF/classes/alfresco/core-services-context.xml–>
   <bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
      <property name="host">
         <value>${mail.host}</value>
      </property>
      <property name="port">
         <value>${mail.port}</value>
      </property>
      <property name="username">
         <value>${mail.username}</value>
      </property>
      <property name="password">
         <value>${mail.password}</value>
      </property>
      <property name="defaultEncoding">
         <value>${mail.encoding}</value>
      </property>
      <property name="javaMailProperties">
         <props>
            <prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
            <prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
         </props>
      </property>
   </bean>

   <bean id="emConAux" class="org.alfresco.web.webscripts.EmConAux">
   </bean>



¿Alguna idea de donde puede venir el problema?

Muchas gracias

Outcomes