5 Replies Latest reply on Jun 22, 2010 3:53 AM by Eduard Queraltó

    Send mail with SeamMail

    Eduard Queraltó Newbie
      Hello. I'm trying to send mail with seam mail. We have a mail template (mail.xhtml), and i've configured an SMTP server via the Seam mailSession component in components.xml.

      In my home class add the next code:

      public void send() {
            try {
            renderer.render("/Mail.xhtml");
            FacesMessages.instance().add("Email sent successfully");
            } catch (Exception e) {
               FacesMessages.instance().add("Email sending failed: " + e.getMessage());
            }
         }


      Throws the exception: Email sending failed: javax.faces.FacesException: Cant instantiate class: org.jboss.seam.mail.ui.UIMessage.

      I've the corresponfding jars in lib folder.

      Can you help me?

      Thanks.
        • 1. Re: Send mail with SeamMail
          Tauseef Ahmed Newbie

          Can u post complete stack trace...

          • 2. Re: Send mail with SeamMail
            Eduard Queraltó Newbie

            Hello Tauseef.


            The complete stack trace: (is possible that i need the mail.jar from java mail api?)


            ADVERTENCIA: JSF1004: Cannot instantiate component of type org.jboss.seam.mail.ui.UIMessage
            javax.faces.FacesException: javax.faces.FacesException: Cant instantiate class: org.jboss.seam.mail.ui.UIMessage.
                 at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:558)
                 at org.jboss.seam.jsf.SeamApplication.createComponent(SeamApplication.java:92)
                 at com.sun.facelets.tag.jsf.ComponentHandler.createComponent(ComponentHandler.java:243)
                 at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:139)
                 at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
                 at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
                 at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
                 at org.jboss.seam.ui.facelet.RendererRequest.renderFacelet(RendererRequest.java:135)
                 at org.jboss.seam.ui.facelet.RendererRequest.run(RendererRequest.java:103)
                 at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:43)
                 at es.sopra.mutua.session.ModalImpressioHome.send(ModalImpressioHome.java:305)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                 at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                 at es.sopra.mutua.session.ModalImpressioHome$$javassistseam52.send(ModalImpressioHome$$javassistseam52.java)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                 at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
                 at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
                 at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                 at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                 at org.jboss.seam.el.OptionalParameterMethodExpression.invoke(OptionalParameterMethodExpression.java:45)
                 at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                 at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:99)
                 at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                 at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
                 at javax.faces.component.UICommand.broadcast(UICommand.java:372)
                 at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                 at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                 at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                 at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
                 at java.lang.Thread.run(Thread.java:619)
            Caused by: javax.faces.FacesException: Cant instantiate class: org.jboss.seam.mail.ui.UIMessage.
                 at com.sun.faces.application.ApplicationImpl.newThing(ApplicationImpl.java:1040)
                 at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:552)
                 ... 85 more
            Caused by: java.lang.NoClassDefFoundError: javax/mail/internet/MimeMessage
                 at java.lang.Class.getDeclaredConstructors0(Native Method)
                 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
                 at java.lang.Class.getConstructor0(Class.java:2699)
                 at java.lang.Class.newInstance0(Class.java:326)
                 at java.lang.Class.newInstance(Class.java:308)
                 at com.sun.faces.application.ApplicationImpl.newThing(ApplicationImpl.java:1038)
                 ... 86 more
            Caused by: java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage
                 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
                 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
                 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                 ... 92 more

            • 3. Re: Send mail with SeamMail
              Tauseef Ahmed Newbie

              There may be an error in your Mail.xhtml, can u post it.


              Usually UIMesage error will come only your mail format is not right.




              Regards,
              Tauseef

              • 4. Re: Send mail with SeamMail
                jo da Newbie

                Caused by: java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage


                find the .jar where this class should be in and add it to your servers classpath

                • 5. Re: Send mail with SeamMail
                  Eduard Queraltó Newbie

                  Thanks for your help. I've added the mail.jar and i've fix the problem!