Documentation for Bamboo 4.0.x. Documentation for earlier versions of Bamboo is available too.

The Bamboo start up script can be customised to setup JNDI resources

Follow this guide to setup Bamboo to use the jetty.xml file

You will also need to change the jetty.xml file under webapp/WEB-INF/classes by change the context path from /bamboo to /. Example of this is below:

If you are using Bamboo 1.2.4 (or earlier):

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Add root context web applications. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Call name="addWebApplication">
    <Arg>/</Arg>
    <Arg>
       <SystemProperty name="bamboo.webapp" default="webapp"/>
    </Arg>
</Call>


If you are using Bamboo 2.0:

<Call name="addHandler">
    <Arg>
       <New class="org.mortbay.jetty.webapp.WebAppContext">
          <Arg name="webApp">
            <SystemProperty name="bamboo.webapp" default="webapp"/>
          </Arg>
          <Arg name="contextPath">
            /
          </Arg>
        </New>
      </Arg>
</Call>


To set up the JNDI mail session, you will also need to uncomment and modify the section of this jetty.xml shown below. You will need to replace the values inside the <Arg> tags with appropriate values (username, password, host, from address).


In Bamboo 1.2.4 and earlier:

<!--
    <Call name="addService">
        <Arg>
            ...
        </Arg>
    </Call>
-->

In Bamboo 2.0:

 <!--
<New id="resourceID" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>resourceName</Arg>
    <Arg>
      <New class="org.mortbay.naming.factories.MailSessionReference">
            ...
      </New>
    </Arg>
 </New>
-->

If you are experiencing class loading problems with your mail session. Try uncommenting the following line in the web applications context (2.0 only):

<!--<Set name="parentLoaderPriority">true</Set>-->
  • No labels

2 Comments

  1. Paudi Moriarty

    To get Bamboo to send mail through smtp.gmail.com, I had to add the following over and above the steps in this guide:

    • jetty.xml:

    Enable jetty-plus configurations:

      <!-- =========================================================== -->
      <!-- Configurations for WebAppContexts                           -->
      <!-- Sequence of configurations to enable Plus features.         -->
      <!-- =========================================================== -->
      <Array id="plusConfig" type="java.lang.String">
          <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
          <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
          <Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
          <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
          <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
      </Array>
    

    Modify the WebAppContext handler, setting configurationClasses to plusConfig:

          <New class="org.mortbay.jetty.webapp.WebAppContext">
            <Arg name="webApp">
                <SystemProperty name="bamboo.webapp" default="/usr/local/bamboo/webapp"/>
            </Arg>
            <Arg name="contextPath">
              /
            </Arg>
            <Set name="configurationClasses"><Ref id="plusConfig"/></Set>*
            <Set name="parentLoaderPriority">true</Set>
          </New>
    
    • web.xml:

    Allow the application to see the JNDI resource:

    <resource-env-ref>
       <resource-env-ref-name>mail/GMail</resource-env-ref-name>
       <resource-env-ref-type>
             javax.mail.Session
       </resource-env-ref-type>
    </resource-env-ref>
    
  2. Anonymous

    Successfully using Google Mail over SSL with JNDI resource "GoogleMail"

    <New id="resourceID">
        <Arg>GoogleMail</Arg>
        <Arg>
          <New>
            <Set name="user">user@example.com</Set>
            <Set name="password">xxx</Set>
            <Set name="properties">
              <New>
                <Put name="mail.smtp.host">smtp.googlemail.com</Put>
                <Put name="mail.smtp.auth">true</Put>
                <Put name="mail.smtp.port">465</Put>
                <Put name="mail.smtp.user">user@example.com</Put>
                <Put name="mail.smtp.starttls.enable">true</Put>
                <Put name="mail.from">user@example.com</Put>
                <Put name="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</Put>
              </New>
            </Set>
          </New>
        </Arg>
      </New>