8 Replies Latest reply on Feb 4, 2007 7:41 AM by pmuir

    Seam mail - How to use the default

    rmemoria

      Hi,

      I'm replacing my previous e-mail code by the new mail features provided by SEAM 1.1.5GA and it's working fine.

      Before that it wasn't necessary to specify the "From" clause since it was specified in the mail-service.xml.

      It is kind handy 'cause in production enviroment is used another mail configuration.

      I tried to "hide" the <m:from /> in my xhtml page, but I got an exception.

      I could create a stateless bean to read the default "from" related to the mailSession, but maybe there is another "easier" solution.

      Any tip?

      regards,
      Ricardo Memória

        • 1. Re: Seam mail - How to use the default
          gavin.king

          <m:from>#{whatever.the.hell.you.like}</m:from>

          • 2. Re: Seam mail - How to use the default
            pmuir

            Another option would be to use a template:

            mailTemplate.xhtml

            <m:message>
             <m:from>default@example.com</m:from>
             <ui:insert name="mail" />
            </m:message>


            <ui:composition template="mailTemplate.xhtml">
             <ui:define name="mail">
             <!-- The rest of your mail-->
             </ui:define>
            </ui:composition>


            • 3. Re: Seam mail - How to use the default
              rmemoria

              Ok...

              ... I'll try to explain in a different way. I'm trying to avoid recompiling the application if I deploy it with a different mail configuration...

              In mail-service.xml I defined the whole mail configuration, including the property mail.from:

              <mbean code="org.jboss.mail.MailService"
               name="jboss:service=Mail">
               <attribute name="JNDIName">java:/Mail</attribute>
               <attribute name="User">mailuser</attribute>
               <attribute name="Password">pass</attribute>
              
               <attribute name="Configuration">
               <!-- Test -->
               <configuration>
               <property name="mail.transport.protocol" value="smtp"/>
               <property name="mail.smtp.host" value="mail.rmemoria.com.br"/>
               <property name="mail.from" value="system@rmemoria.com.br"/>
               <property name="mail.debug" value="false"/>
               <property name="mail.smtp.auth" value="true"/>
               </configuration>
               <depends>jboss:service=Naming</depends>
               </attribute>
               </mbean>


              If I define the property mail.from, I don't have to set the "From" if I send mails using JNDI to bind a javax.mail.Session, cause it's going to use the default specified in my mail-service.xml.

              On the other hand, using the SEAM mail, I ought to inform the clause <m:from> in my .xhtml page. Obviously it's amazingly simpler and more powerful send e-mails using the SEAM mail, but unfortunately I have this restriction.

              So my suggestion is: What about catching the mail.from property defined in mail-service.xml if the clause <m:from> is missing?

              Best,
              Ricardo Memória

              • 4. Re: Seam mail - How to use the default
                pmuir

                Ok, so I take it you are configuring your mailSession in components.xml as <mail:mailSession sessionJndiName="java:/Mail" />?

                Can you post the exception you are getting (I need the full stack trace) please :)

                • 5. Re: Seam mail - How to use the default
                  rmemoria

                  Hi Peter...

                  This is my components.xml

                  <?xml version="1.0" encoding="UTF-8"?>
                  <components xmlns="http://jboss.com/products/seam/components"
                   xmlns:core="http://jboss.com/products/seam/core"
                   xmlns:mail="http://jboss.com/products/seam/mail"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation=
                   "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
                   http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
                  
                   <core:init jndi-pattern="mdrtb-moldova/#{ejbName}/local" debug="true"/>
                  
                   <core:manager conversation-timeout="120000"
                   concurrent-request-timeout="500"
                   conversation-id-parameter="cid"
                   conversation-is-long-running-parameter="clr"/>
                  
                   <core:transactionListener/>
                  
                   <core:ejb installed="@embeddedEjb@"/>
                  
                   <core:managed-persistence-context
                   name="entityManager"
                   auto-create="true"
                   persistence-unit-jndi-name="java:/mdrEntityManagerFactory"/>
                  
                   <mail:mailSession sessionJndiName="java:/Mail" /></components>


                  And this is the stack trace

                  20:40:16,609 ERROR [STDERR] javax.faces.FacesException: 550 Administrative prohibition
                  20:40:16,609 ERROR [STDERR] at org.jboss.seam.mail.ui.UIMessage.encodeEnd(UIMessage.java:107)
                  20:40:16,609 ERROR [STDERR] at org.jboss.seam.ui.JSF.renderChild(JSF.java:179)
                  20:40:16,609 ERROR [STDERR] at org.jboss.seam.ui.JSF.renderChildren(JSF.java:162)
                  20:40:16,609 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer.renderFacelet(FaceletsRenderer.java:105)
                  20:40:16,609 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:53)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:38)
                  20:40:16,984 ERROR [STDERR] at com.rmemoria.mdrtb.seam.UsersBean.sendMail(UsersBean.java:136)
                  20:40:16,984 ERROR [STDERR] at com.rmemoria.mdrtb.seam.UsersBean.save(UsersBean.java:126)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.interceptors.BijectionInterceptor.bijectNonreentrantComponent(BijectionInterceptor.java:79)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.interceptors.BijectionInterceptor.bijectComponent(BijectionInterceptor.java:58)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:36)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor239.invoke(Unknown Source)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:52)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor238.invoke(Unknown Source)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor237.invoke(Unknown Source)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
                  20:40:16,984 ERROR [STDERR] at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  20:40:16,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:16,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:16,984 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
                  20:40:16,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:17,000 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                  20:40:17,000 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  20:40:17,000 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
                  20:40:17,000 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
                  20:40:17,000 ERROR [STDERR] at $Proxy187.save(Unknown Source)
                  20:40:17,000 ERROR [STDERR] at com.rmemoria.mdrtb.seam.UsersLocal$$FastClassByCGLIB$$6569facb.invoke(<generated>)
                  20:40:17,000 ERROR [STDERR] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:74)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:40)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:17,000 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:39)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor236.invoke(Unknown Source)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:17,000 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:83)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:52)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$1b1db64.save(<generated>)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  20:40:17,000 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  20:40:17,000 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
                  20:40:17,000 ERROR [STDERR] at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
                  20:40:17,000 ERROR [STDERR] at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
                  20:40:17,000 ERROR [STDERR] at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                  20:40:17,000 ERROR [STDERR] at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
                  20:40:17,000 ERROR [STDERR] at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
                  20:40:17,000 ERROR [STDERR] at javax.faces.component.UICommand.broadcast(UICommand.java:106)
                  20:40:17,000 ERROR [STDERR] at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
                  20:40:17,000 ERROR [STDERR] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
                  20:40:17,000 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
                  20:40:17,000 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
                  20:40:17,000 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                  20:40:17,000 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                  20:40:17,000 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                  20:40:17,000 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                  20:40:17,000 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                  20:40:17,000 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                  20:40:17,000 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                  
                  20:40:17,000 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                  20:40:17,000 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                  20:40:17,000 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                  20:40:17,000 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
                  20:40:17,000 ERROR [STDERR] Caused by: com.sun.mail.smtp.SMTPSendFailedException: 550 Administrative prohibition
                  20:40:17,000 ERROR [STDERR] at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
                  20:40:17,000 ERROR [STDERR] at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1215)
                  20:40:17,000 ERROR [STDERR] at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:586)
                  20:40:17,000 ERROR [STDERR] at javax.mail.Transport.send0(Transport.java:169)
                  20:40:17,000 ERROR [STDERR] at javax.mail.Transport.send(Transport.java:98)
                  20:40:17,000 ERROR [STDERR] at org.jboss.seam.mail.ui.UIMessage.encodeEnd(UIMessage.java:103)
                  20:40:17,000 ERROR [STDERR] ... 152 more


                  Thanks,
                  Ricardo Memória


                  • 6. Re: Seam mail - How to use the default
                    pmuir

                    Here's a partial explanation:

                    The reason you get an exception is that your smtp server rejects the connection as there is no from address in the email (this is 550 administrative error bit). Fortunately my smtp server doesn't :) I can see from the email sent that the return-path is correctly set (to that from mail-service.xml) but not the from address.

                    You say this worked when you did a JNDI lookup for the mail service. Could you post the code you used to send an email where it worked?

                    Thanks

                    • 7. Re: Seam mail - How to use the default
                      rmemoria

                      Actually the code above check if the mailFrom argument is null.

                      If it's null it recovers from the mail-service.xml

                      public class SendMail {
                      
                      public static Session newMailSession() {
                       try {
                       Object ctx = new InitialContext().lookup("java:/Mail");
                      
                       return (Session)PortableRemoteObject.narrow(ctx, Session.class);
                       } catch (javax.naming.NamingException e) {
                       e.printStackTrace();
                       return null;
                       }
                      }
                      
                      public static void sendMessage(String mailFrom, String mailTo, String subject, String msg, boolean htmlText)
                      {
                       try
                       {
                       Session session = newMailSession();
                       Message message = new MimeMessage(session);
                      
                       if (mailFrom == null)
                       mailFrom = session.getProperty("mail.from"); message.setFrom( new InternetAddress(mailFrom));
                      
                       InternetAddress to[] = new InternetAddress[1];
                       to[0] = new InternetAddress(mailTo);
                       message.setRecipients(Message.RecipientType.TO, to);
                       message.setSubject(subject);
                       message.setSentDate(new Date());
                      
                       String textType;
                       if (htmlText)
                       textType = "text/html";
                       else textType = "text/plain";
                       message.setContent(msg, textType);
                      
                       Transport trans = session.getTransport("smtp");
                      
                       trans.connect(session.getProperty("mail.smtp.host"),
                       session.getProperty("mail.smtp.user"),
                       session.getProperty("mail.smtp.password"));
                       trans.sendMessage(message, message.getAllRecipients());
                       trans.close();
                       }
                       catch (Exception e)
                       {
                       e.printStackTrace();
                       }
                      }


                      • 8. Re: Seam mail - How to use the default
                        pmuir

                        Ah :)

                        Having looked JavaMail sendMessage() I was wondering how it was uisng mail.from to set the From: address (as opposed to the Return-path:)

                        I'm not really convinced that this is a good hack. The same thing can be easily avoided with no recompilation:

                        1) either edit a facelets template or

                        2) components.xml

                        (n.b. you could easily use ant to do this)

                        Or, if you are really don't like this, extend UIMessage and in encodeEnd use something like:

                        if (findMimeMessage().getFrom() == null) {
                         mailFrom = getMailSession().getProperty("mail.from");
                         findMimeMessage().setFrom(new InternetAddress(mailFrom));
                        }
                        super.encodeEnd(contenxt);