| <!DOCTYPE html> |
| <html lang="en"> |
| |
| <head> |
| <meta charset="UTF-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <title>Apache TomEE</title> |
| <meta name="description" |
| content="Apache TomEE is a lightweight, yet powerful, JavaEE Application server with feature rich tooling." /> |
| <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" /> |
| <meta name="author" content="Luka Cvetinovic for Codrops" /> |
| <link rel="icon" href="../../favicon.ico"> |
| <link rel="icon" type="image/png" href="../../favicon.png"> |
| <meta name="msapplication-TileColor" content="#80287a"> |
| <meta name="theme-color" content="#80287a"> |
| <link rel="stylesheet" type="text/css" href="../../css/normalize.css"> |
| <link rel="stylesheet" type="text/css" href="../../css/bootstrap.css"> |
| <link rel="stylesheet" type="text/css" href="../../css/owl.css"> |
| <link rel="stylesheet" type="text/css" href="../../css/animate.css"> |
| <link rel="stylesheet" type="text/css" href="../../fonts/font-awesome-4.1.0/css/font-awesome.min.css"> |
| <link rel="stylesheet" type="text/css" href="../../fonts/eleganticons/et-icons.css"> |
| <link rel="stylesheet" type="text/css" href="../../css/jqtree.css"> |
| <link rel="stylesheet" type="text/css" href="../../css/idea.css"> |
| <link rel="stylesheet" type="text/css" href="../../css/cardio.css"> |
| |
| <script type="text/javascript"> |
| <!-- Matomo --> |
| var _paq = window._paq = window._paq || []; |
| /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ |
| /* We explicitly disable cookie tracking to avoid privacy issues */ |
| _paq.push(['disableCookies']); |
| _paq.push(['trackPageView']); |
| _paq.push(['enableLinkTracking']); |
| (function () { |
| var u = "//matomo.privacy.apache.org/"; |
| _paq.push(['setTrackerUrl', u + 'matomo.php']); |
| _paq.push(['setSiteId', '5']); |
| var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; |
| g.async = true; |
| g.src = u + 'matomo.js'; |
| s.parentNode.insertBefore(g, s); |
| })(); |
| <!-- End Matomo Code --> |
| </script> |
| </head> |
| |
| <body> |
| <div class="preloader"> |
| <img src="../../img/loader.gif" alt="Preloader image"> |
| </div> |
| <nav class="navbar"> |
| <div class="container"> |
| <div class="row"> <div class="col-md-12"> |
| |
| <!-- Brand and toggle get grouped for better mobile display --> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <a class="navbar-brand" href="/" title="Apache TomEE"> |
| <span> |
| |
| |
| <img |
| src="../../img/apache_tomee-logo.svg" |
| onerror="this.src='../../img/apache_tomee-logo.jpg'" |
| height="50" |
| > |
| |
| |
| </span> |
| </a> |
| </div> |
| <!-- Collect the nav links, forms, and other content for toggling --> |
| <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> |
| <ul class="nav navbar-nav navbar-right main-nav"> |
| <li><a href="../../docs.html">Documentation</a></li> |
| <li><a href="../../community/index.html">Community</a></li> |
| <li><a href="../../security/security.html">Security</a></li> |
| <li><a class="btn btn-accent accent-orange no-shadow" href="../../download.html">Downloads</a></li> |
| </ul> |
| </div> |
| <!-- /.navbar-collapse --> |
| </div></div> |
| </div> |
| <!-- /.container-fluid --> |
| </nav> |
| |
| |
| <div id="main-block" class="container main-block"> |
| <div class="row title"> |
| <div class="col-md-12"> |
| <div class='page-header'> |
| |
| <h1>Javamail API with Apache Velocity Templating</h1> |
| </div> |
| </div> |
| </div> |
| <div class="row"> |
| |
| <div class="col-md-12"> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>This examples demonstrates the use of the Javamail API in combination with <a href="https://velocity.apache.org/">Apache Velocity</a> to create templated HTML Emails.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_a_simple_stateless_service_using_the_javamail_api">A simple @Stateless service using the Javamail API</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Here we see a very simple <code>@Stateless</code> service that can be called to send an Email. |
| It uses <a href="https://velocity.apache.org/">Apache Velocity</a> to load velocity templates from a pre-defined location <code>templates</code>, which is located in the <code>resources</code> folder.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Please note, that we need to use some additional velocity configuration options to specify <code>org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</code> |
| as a resource loader in order to actually load the templates when running inside TomEE.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-java" data-lang="java">package org.superbiz; |
| |
| import org.apache.velocity.Template; |
| import org.apache.velocity.VelocityContext; |
| import org.apache.velocity.app.VelocityEngine; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| import jakarta.annotation.PostConstruct; |
| import jakarta.annotation.PreDestroy; |
| import jakarta.annotation.Resource; |
| import jakarta.ejb.Stateless; |
| import jakarta.mail.*; |
| import jakarta.mail.internet.InternetAddress; |
| import jakarta.mail.internet.MimeBodyPart; |
| import jakarta.mail.internet.MimeMessage; |
| import jakarta.mail.internet.MimeMultipart; |
| import java.io.StringWriter; |
| import java.util.Date; |
| import java.util.Map; |
| import java.util.Properties; |
| |
| @Stateless |
| public class EMailServiceImpl { |
| |
| private static final Logger LOGGER = LoggerFactory.getLogger(EMailServiceImpl.class); |
| |
| private static final String HEADER_HTML_EMAIL = "text/html; charset=UTF-8"; |
| private static final String TEMPLATE_DIRECTORY = "templates/"; |
| private static final String VELOCITY_RESOURCE_CLASS_LOADER_KEY = "resource.loader.class.class"; |
| private static final String VELOCITY_RESOURCE_CLASS_LOADER = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"; |
| private static final String VELOCITY_RESOURCE_LOADER_KEY = "resource.loaders"; |
| private static final String VELOCITY_RESOURCE_LOADER = "class"; |
| |
| @Resource(mappedName = "java:comp/env/tomee/mail/exampleSMTP") |
| private Session mailSession; |
| |
| private VelocityEngine velocityEngine; |
| |
| @PostConstruct |
| public void init() { |
| // Properties documented here: https://wiki.apache.org/velocity/VelocityAndWeblogic |
| final Properties prop = new Properties(); |
| prop.setProperty(VELOCITY_RESOURCE_LOADER_KEY, VELOCITY_RESOURCE_LOADER); |
| prop.setProperty(VELOCITY_RESOURCE_CLASS_LOADER_KEY, VELOCITY_RESOURCE_CLASS_LOADER); |
| |
| velocityEngine = new VelocityEngine(); |
| velocityEngine.init(prop); |
| |
| /* Ensures that smtp authentication mechanism works as configured */ |
| boolean authenticate = "true".equals(mailSession.getProperty("mail.smtp.auth")); |
| if (authenticate) { |
| final String username = mailSession.getProperty("mail.smtp.user"); |
| final String password = mailSession.getProperty("mail.smtp.password"); |
| |
| final URLName url = new URLName( |
| mailSession.getProperty("mail.transport.protocol"), |
| mailSession.getProperty("mail.smtp.host"), -1, null, |
| username, null); |
| |
| mailSession.setPasswordAuthentication(url, new PasswordAuthentication(username, password)); |
| } else { |
| LOGGER.warn("Using EMailService without SMTP auth configured. This might be valid, but could also be dangerous!"); |
| } |
| |
| } |
| |
| public void sendMail(EMail eMail, String htmlTemplate, Map<String, String> templateResources) { |
| if (!eMail.getMailType().equals(MailType.MAIL_HTML)) { |
| throw new RuntimeException("You can't send an HTML eMail with the Mail instance provided: '" + eMail.getMailType().toString() + "'!"); |
| } else { |
| htmlTemplate = TEMPLATE_DIRECTORY + htmlTemplate; |
| try { |
| MimeMessage message = createMimeMessage(eMail); |
| |
| if (!velocityEngine.resourceExists(htmlTemplate)) { |
| throw new RuntimeException("Could not find the given email template '" + htmlTemplate + "' in the classpath."); |
| } else { |
| final Template template = velocityEngine.getTemplate(htmlTemplate); |
| final VelocityContext velocityContext = new VelocityContext(); |
| for (Map.Entry<String, String> templateEntry : templateResources.entrySet()) { |
| velocityContext.put(templateEntry.getKey(), templateEntry.getValue()); |
| } |
| final StringWriter stringWriter = new StringWriter(); |
| template.merge(velocityContext, stringWriter); |
| // setting the eMail's content as HTML mail body |
| final Multipart mp = new MimeMultipart(); |
| final MimeBodyPart htmlPart = new MimeBodyPart(); |
| htmlPart.setContent(stringWriter.toString(), HEADER_HTML_EMAIL); |
| mp.addBodyPart(htmlPart); |
| message.setContent(mp); |
| |
| Transport.send(message); |
| // mark this eMail as sent with the current date |
| eMail.setSentDate(new Date()); |
| } |
| |
| } catch (MessagingException ex) { |
| LOGGER.warn("Could not send template HTML eMail: {}", ex.getLocalizedMessage()); |
| throw new RuntimeException(ex.getLocalizedMessage(), ex); |
| } |
| } |
| } |
| |
| private MimeMessage createMimeMessage(EMail eMail) throws MessagingException { |
| MimeMessage message = new MimeMessage(mailSession); |
| message.setFrom(new InternetAddress(eMail.getMailFrom())); |
| for (String mailTo : eMail.getMailTo()) { |
| message.addRecipient(Message.RecipientType.TO, new InternetAddress(mailTo)); |
| } |
| |
| message.setSubject(eMail.getMailSubject()); |
| message.setSentDate(new Date()); |
| |
| for (String ccRecipient : eMail.getMailCc()) { |
| message.addRecipient(Message.RecipientType.CC, new InternetAddress(ccRecipient)); |
| } |
| for (String bccRecipient : eMail.getMailBcc()) { |
| message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bccRecipient)); |
| } |
| return message; |
| } |
| |
| @PreDestroy |
| public void close() { |
| if (mailSession != null) { |
| mailSession = null; |
| } |
| } |
| }</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The configuration of the mail session can be done via a <code>resource.xml</code>, which looks like</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="utf-8"?> |
| <resources> |
| <Resource id="tomee/mail/exampleSMTP" type="jakarta.mail.Session"> |
| mail.debug=false |
| mail.transport.protocol=smtp |
| mail.smtp.starttls.enable=true |
| mail.smtp.starttls.required=true |
| <!-- mail.smtp.ssl.protocols=TLSv1.2 TLSv1.3 --> |
| <!-- mail.smtp.ssl.ciphersuites=TLS_AES_128_GCM_SHA256 TLS_AES_256_GCM_SHA384 --> |
| mail.smtp.host=mail.mymailprovider.com |
| mail.smtp.port=587 |
| mail.smtp.auth=true |
| mail.smtp.user=myself@mymailprovider.com |
| <!-- your password, and not 'mail.smtp.password' --> |
| password=mypassword |
| </Resource> |
| </resources></code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>You can tune this <code>resource.xml</code> for your specific Email provider. Please note, that you can specifiy the <code>ssl.protocols</code> and <code>ciphersuites</code>, which are used to connect to the specific mail server. |
| If not specified, JVM defaults are used.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_testing">Testing</h2> |
| <div class="sectionbody"> |
| <div class="sect2"> |
| <h3 id="_test_for_the_emailservice">Test for the EMailService</h3> |
| <div class="paragraph"> |
| <p>The test uses the ApplicationComposer to make testing easy. |
| To test our service, we rely on <a href="https://greenmail-mail-test.github.io/greenmail/">GreenMail</a>, |
| which allows us to spawn a catch-all smtp server during the unit test.</p> |
| </div> |
| <div class="paragraph"> |
| <p>The idea is to create our <code>EMailServiceImpl</code> by creating a <code>EjbJar</code> on the fly. |
| To do so, we add <code>@Classes</code> annotation to define the set of classes to use in the <code>EjbJar</code>. |
| In addition, we use <code>@Configuration</code> to define the Mail Session Resource for the test context to ensure, |
| that we are not bound to a pre-defined port.As mentioned above, the <code>resource.xml</code> can also be used to configure the mail session.. |
| Finally, we use our service to send an Email to our catch-all smtp server and check the related results.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-java" data-lang="java">package org.superbiz; |
| |
| import com.icegreen.greenmail.util.GreenMail; |
| import com.icegreen.greenmail.util.ServerSetup; |
| |
| import org.apache.openejb.jee.EjbJar; |
| import org.apache.openejb.junit5.RunWithApplicationComposer; |
| import org.apache.openejb.testing.Classes; |
| import org.apache.openejb.testing.Configuration; |
| import org.apache.openejb.testing.Module; |
| import org.apache.openejb.util.NetworkUtil; |
| import org.junit.jupiter.api.AfterAll; |
| import org.junit.jupiter.api.BeforeAll; |
| import org.junit.jupiter.api.Test; |
| |
| import jakarta.inject.Inject; |
| import jakarta.mail.BodyPart; |
| import jakarta.mail.internet.MimeMessage; |
| import jakarta.mail.internet.MimeMultipart; |
| |
| import java.util.ArrayList; |
| import java.util.Collection; |
| import java.util.Collections; |
| import java.util.HashMap; |
| import java.util.Map; |
| import java.util.Properties; |
| import java.util.concurrent.CountDownLatch; |
| |
| import static org.junit.jupiter.api.Assertions.*; |
| |
| @RunWithApplicationComposer |
| public class EMailServiceTest { |
| |
| private static final int SMTP_TEST_PORT = NetworkUtil.getNextAvailablePort(); |
| private static final String USER_PASSWORD = "s3cr3t"; |
| private static final String USER_NAME = "admin@localhost"; |
| private static final String EMAIL_USER_ADDRESS = "admin@localhost"; |
| |
| private static GreenMail mailServer; |
| private static CountDownLatch started = new CountDownLatch(1); |
| |
| @Module |
| @Classes(cdi = true, value = {EMailServiceImpl.class}) |
| public EjbJar beans() { |
| return new EjbJar("javamail-velocity"); |
| } |
| |
| @Configuration |
| public Properties config() { |
| //Note: We can also configure this via a resource.xml or via tomee.xml |
| Properties properties = new Properties(); |
| properties.put("tomee/mail/mySMTP", "new://Resource?type=jakarta.mail.Session"); |
| properties.put("tomee/mail/mySMTP.mail.debug", "false"); |
| properties.put("tomee/mail/mySMTP.mail.transport.protocol", "smtp"); |
| properties.put("tomee/mail/mySMTP.mail.smtp.host", "localhost"); |
| properties.put("tomee/mail/mySMTP.mail.smtp.port", SMTP_TEST_PORT); |
| properties.put("tomee/mail/mySMTP.mail.smtp.auth", "true"); |
| properties.put("tomee/mail/mySMTP.mail.smtp.user", USER_NAME); |
| properties.put("tomee/mail/mySMTP.password", USER_PASSWORD); |
| return properties; |
| } |
| |
| @Inject |
| private EMailServiceImpl eMailService; |
| |
| @BeforeAll |
| public static void setUp() throws InterruptedException { |
| mailServer = new CustomGreenMailServer(new ServerSetup(SMTP_TEST_PORT, null, "smtp")); |
| mailServer.start(); |
| |
| //wait for the server startup... |
| started.await(); |
| |
| // create user on mail server |
| mailServer.setUser(EMAIL_USER_ADDRESS, USER_NAME, USER_PASSWORD); |
| } |
| |
| @AfterAll |
| public static void tearDown() { |
| if (mailServer != null) { |
| mailServer.stop(); |
| } |
| } |
| |
| @Test |
| public void testSendMailHTMLTemplate() throws Exception { |
| // prepare |
| String eMailTemplateName = "email-html-template.vm"; |
| Map<String, String> mailTemplateProps = new HashMap<>(); |
| mailTemplateProps.put("name", "Jon Doe"); |
| |
| String fromMail = "admin@localhost"; |
| String toEmail = "john@localhost.com"; |
| String subject = "Template HTML email!"; |
| |
| Collection<String> toRecipients = new ArrayList<>(); |
| toRecipients.add(toEmail); |
| |
| EMail eMail = new EMail(MailType.MAIL_HTML,toRecipients, subject, "", Collections.emptyList(),Collections.emptyList()); |
| eMail.setMailFrom(fromMail); |
| // test |
| assertNull(eMail.getSentDate()); |
| eMailService.sendMail(eMail, eMailTemplateName, mailTemplateProps); |
| assertNotNull(eMail.getSentDate()); |
| |
| // fetch messages from server |
| MimeMessage[] messages = mailServer.getReceivedMessages(); |
| assertNotNull(messages); |
| assertEquals(1, messages.length); |
| MimeMessage msg = messages[0]; |
| assertTrue(msg.getContentType().contains("multipart/mixed;")); |
| |
| assertEquals(subject, msg.getSubject()); |
| |
| MimeMultipart message = (MimeMultipart) msg.getContent(); |
| BodyPart bodyPart = message.getBodyPart(0); |
| assertEquals("text/html; charset=UTF-8", bodyPart.getHeader("Content-Type")[0]); |
| String receivedMailContent = String.valueOf(bodyPart.getContent()); |
| |
| assertTrue(receivedMailContent.contains("Dear Jon Doe")); |
| assertTrue(receivedMailContent.contains("templated")); |
| assertEquals(fromMail, msg.getFrom()[0].toString()); |
| } |
| |
| public static class CustomGreenMailServer extends GreenMail { |
| |
| public CustomGreenMailServer(ServerSetup config) { |
| super(new ServerSetup[]{config}); |
| } |
| |
| public synchronized void start() { |
| super.start(); |
| started.countDown(); |
| } |
| } |
| }</code></pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_running">Running</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Running the example is fairly simple. In the <code>javamail-velocity</code> directory run:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-java" data-lang="java">$ mvn clean install</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>Which should create output as follows:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-java" data-lang="java">[INFO] Running org.superbiz.EMailServiceTest |
| Okt 25, 2021 4:38:24 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@55fe41ea |
| Okt 25, 2021 4:38:24 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Succeeded in installing singleton service |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed. |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Creating TransactionManager(id=Default Transaction Manager) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Creating SecurityService(id=Default Security Service) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Configuring enterprise application: /home/rzo1/coding/tomee/examples/javamail-velocity/EMailServiceTest |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-deploying ejb EMailServiceImpl: EjbDeployment(deployment-id=EMailServiceImpl) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Configuring Service(id=EMailServiceTest/tomee/mail/mySMTP, type=Resource, provider-id=Default Mail Session) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Creating Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-creating a container for bean org.superbiz.EMailServiceTest: Container(type=MANAGED, id=Default Managed Container) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Creating Container(id=Default Managed Container) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Using directory /tmp for stateful session passivation |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/EMailServiceTest/tomee/mail/mySMTP' in bean org.superbiz.EMailServiceTest to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/tomee/mail/mySMTP' in bean org.superbiz.EMailServiceTest to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/EMailServiceTest/tomee/mail/mySMTP' in bean EjbModule652176954.Comp937277082 to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/tomee/mail/mySMTP' in bean EjbModule652176954.Comp937277082 to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-creating a container for bean EMailServiceImpl: Container(type=STATELESS, id=Default Stateless Container) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Creating Container(id=Default Stateless Container) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'java:comp/env/org.superbiz.EMailServiceImpl/mailSession' in bean EMailServiceImpl to Resource(id=tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/EMailServiceTest/tomee/mail/mySMTP' in bean EMailServiceImpl to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/tomee/mail/mySMTP' in bean EMailServiceImpl to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'java:comp/env/org.superbiz.EMailServiceImpl/mailSession' in bean javamail-velocity.Comp234740890 to Resource(id=tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/EMailServiceTest/tomee/mail/mySMTP' in bean javamail-velocity.Comp234740890 to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Auto-linking resource-ref 'openejb/Resource/tomee/mail/mySMTP' in bean javamail-velocity.Comp234740890 to Resource(id=EMailServiceTest/tomee/mail/mySMTP) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Enterprise application "/home/rzo1/coding/tomee/examples/javamail-velocity/EMailServiceTest" loaded. |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Not creating another application classloader for EMailServiceTest |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Assembling app: /home/rzo1/coding/tomee/examples/javamail-velocity/EMailServiceTest |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Jndi(name=EMailServiceImplLocalBean) --> Ejb(deployment-id=EMailServiceImpl) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Jndi(name=global/EMailServiceTest/javamail-velocity/EMailServiceImpl!org.superbiz.EMailServiceImpl) --> Ejb(deployment-id=EMailServiceImpl) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Jndi(name=global/EMailServiceTest/javamail-velocity/EMailServiceImpl) --> Ejb(deployment-id=EMailServiceImpl) |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@55fe41ea |
| Okt 25, 2021 4:38:25 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: OpenWebBeans Container is starting... |
| Okt 25, 2021 4:38:25 PM org.apache.webbeans.plugins.PluginLoader startUp |
| INFORMATION: Adding OpenWebBeansPlugin : [CdiPlugin] |
| Okt 25, 2021 4:38:26 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints |
| INFORMATION: All injection points were validated successfully. |
| Okt 25, 2021 4:38:26 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: OpenWebBeans Container has started, it took 758 ms. |
| Okt 25, 2021 4:38:26 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Created Ejb(deployment-id=EMailServiceImpl, ejb-name=EMailServiceImpl, container=Default Stateless Container) |
| Okt 25, 2021 4:38:26 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Started Ejb(deployment-id=EMailServiceImpl, ejb-name=EMailServiceImpl, container=Default Stateless Container) |
| Okt 25, 2021 4:38:26 PM org.apache.batchee.container.services.ServicesManager init |
| WARNUNG: You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping |
| Okt 25, 2021 4:38:26 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Deployed Application(path=/home/rzo1/coding/tomee/examples/javamail-velocity/EMailServiceTest) |
| Okt 25, 2021 4:38:26 PM com.icegreen.greenmail.smtp.SmtpManager$Incoming handle |
| INFORMATION: Created user login john@localhost.com for address john@localhost.com with password john@localhost.com because it didn't exist before. |
| Okt 25, 2021 4:38:26 PM org.apache.openejb.util.LogStreamAsync run |
| INFORMATION: Undeploying app: /home/rzo1/coding/tomee/examples/javamail-velocity/EMailServiceTest |
| [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.179 s - in org.superbiz.EMailServiceTest</code></pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_apis_used">APIs Used</h2> |
| <div class="sectionbody"> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><a href="../../master/javadoc/org/apache/openejb/jee/EjbJar.html">org.apache.openejb.jee.EjbJar</a></p> |
| </li> |
| <li> |
| <p><a href="../../master/javadoc/org/apache/openejb/junit5/RunWithApplicationComposer.html">org.apache.openejb.junit5.RunWithApplicationComposer</a></p> |
| </li> |
| <li> |
| <p><a href="../../master/javadoc/org/apache/openejb/testing/Classes.html">org.apache.openejb.testing.Classes</a></p> |
| </li> |
| <li> |
| <p><a href="../../master/javadoc/org/apache/openejb/testing/Configuration.html">org.apache.openejb.testing.Configuration</a></p> |
| </li> |
| <li> |
| <p><a href="../../master/javadoc/org/apache/openejb/testing/Module.html">org.apache.openejb.testing.Module</a></p> |
| </li> |
| <li> |
| <p><a href="../../master/javadoc/org/apache/openejb/util/NetworkUtil.html">org.apache.openejb.util.NetworkUtil</a></p> |
| </li> |
| <li> |
| <p><a href="../../jakartaee-9.0/javadoc/jakarta/annotation/PostConstruct.html">jakarta.annotation.PostConstruct</a></p> |
| </li> |
| <li> |
| <p><a href="../../jakartaee-9.0/javadoc/jakarta/annotation/PreDestroy.html">jakarta.annotation.PreDestroy</a></p> |
| </li> |
| <li> |
| <p><a href="../../jakartaee-9.0/javadoc/jakarta/annotation/Resource.html">jakarta.annotation.Resource</a></p> |
| </li> |
| <li> |
| <p><a href="../../jakartaee-9.0/javadoc/jakarta/ejb/Stateless.html">jakarta.ejb.Stateless</a></p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| <div style="margin-bottom: 30px;"></div> |
| <footer> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-sm-6 text-center-mobile"> |
| <h3 class="white">Be simple. Be certified. Be Tomcat.</h3> |
| <h5 class="light regular light-white">"A good application in a good server"</h5> |
| <ul class="social-footer"> |
| <li><a href="https://www.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li> |
| <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li> |
| </ul> |
| <h5 class="light regular light-white"> |
| <a href="../../privacy-policy.html" class="white">Privacy Policy</a> |
| </h5> |
| </div> |
| <div class="col-sm-6 text-center-mobile"> |
| <div class="row opening-hours"> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../latest/docs/" class="white">Documentation</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="../../latest/docs/admin/configuration/index.html" class="regular light-white">How to configure</a></li> |
| <li><a href="../../latest/docs/admin/file-layout.html" class="regular light-white">Dir. Structure</a></li> |
| <li><a href="../../latest/docs/developer/testing/index.html" class="regular light-white">Testing</a></li> |
| <li><a href="../../latest/docs/admin/cluster/index.html" class="regular light-white">Clustering</a></li> |
| </ul> |
| </div> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../latest/examples/" class="white">Examples</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="../../latest/examples/simple-cdi-interceptor.html" class="regular light-white">CDI Interceptor</a></li> |
| <li><a href="../../latest/examples/rest-cdi.html" class="regular light-white">REST with CDI</a></li> |
| <li><a href="../../latest/examples/ejb-examples.html" class="regular light-white">EJB</a></li> |
| <li><a href="../../latest/examples/jsf-managedBean-and-ejb.html" class="regular light-white">JSF</a></li> |
| </ul> |
| </div> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../community/index.html" class="white">Community</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="../../community/contributors.html" class="regular light-white">Contributors</a></li> |
| <li><a href="../../community/social.html" class="regular light-white">Social</a></li> |
| <li><a href="../../community/sources.html" class="regular light-white">Sources</a></li> |
| </ul> |
| </div> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../security/index.html" class="white">Security</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="https://apache.org/security" target="_blank" class="regular light-white">Apache Security</a></li> |
| <li><a href="https://apache.org/security/projects.html" target="_blank" class="regular light-white">Security Projects</a></li> |
| <li><a href="https://cve.mitre.org" target="_blank" class="regular light-white">CVE</a></li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="row bottom-footer text-center-mobile"> |
| <div class="col-sm-12 light-white"> |
| <p>Copyright © 1999-2022 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p> |
| </div> |
| </div> |
| </div> |
| </footer> |
| <!-- Holder for mobile navigation --> |
| <div class="mobile-nav"> |
| <ul> |
| <li><a hef="../../latest/docs/admin/index.html">Administrators</a> |
| <li><a hef="../../latest/docs/developer/index.html">Developers</a> |
| <li><a hef="../../latest/docs/advanced/index.html">Advanced</a> |
| <li><a hef="../../community/index.html">Community</a> |
| </ul> |
| <a href="#" class="close-link"><i class="arrow_up"></i></a> |
| </div> |
| <!-- Scripts --> |
| <script src="../../js/jquery-1.11.1.min.js"></script> |
| <script src="../../js/owl.carousel.min.js"></script> |
| <script src="../../js/bootstrap.min.js"></script> |
| <script src="../../js/wow.min.js"></script> |
| <script src="../../js/typewriter.js"></script> |
| <script src="../../js/jquery.onepagenav.js"></script> |
| <script src="../../js/tree.jquery.js"></script> |
| <script src="../../js/highlight.pack.js"></script> |
| <script src="../../js/main.js"></script> |
| </body> |
| |
| </html> |
| |