geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Mulder" <ammul...@alumni.princeton.edu>
Subject Re: Mailing from geronimo
Date Sat, 30 Sep 2006 16:05:31 GMT
I was going to suggest adding a dependency on the existing JavaMail
module (which I think is something like geronimo/javamail/1.1.1/car),
though you'd have to override the SMTP server in config.xml.  I
haven't had a chance to try an example to get the specific syntax
together, though.  I'll try to do that this weekend.

Rick, for what it's worth, the Quartz plan takes a <environment>
element like any other Geronimo plan, so either JAR or module
dependencies should be able to be added there.

Thanks,
     Aaron

On 9/30/06, Rick McGuire <rickmcg@gmail.com> wrote:
> Peter Petersson wrote:
> > Okey here comes the plans and a code snippet illustrating what im
> > trying to do when i get the
> > javax.mail.NoSuchProviderException: Unable to locate provider for
> > protocol: smtp
> >       at javax.mail.Session.getProvider(Session.java:227)
> >       at javax.mail.Session.getTransport(Session.java:336)
> >
> > Anny suggestions ?
> The NoSuchProviderException usually occurs because the
> javamail-transport jar file isn't in the classpath, but you have the
> correct dependency there, so this should be working.  I'm going to have
> to investigate this a little more.  Any chance you can send me your
> sample app (with any special usage/setup instructions) so I can try to
> sort this out?
>
> Rick
>
>
> >
> > The execute method below hass the intresting mailing part (its a bit
> > messy as I have tryed diffrent approaches
> > Code snippet:
> > public class UsedAllotmentSendJob implements Job {
> >
> >    private final static Log logger =
> > LogFactory.getLog(UsedAllotmentSendJob.class);
> >    private DataSource dataSource;
> >    private Session mailSession;
> >
> >    public void setDatabase(DataSource ds) {
> >        dataSource = ds;
> >    }
> >
> >    public void setMailSession(Session s) {
> >        mailSession = s;
> >    }        public void execute(JobExecutionContext jobcontext) throws
> > JobExecutionException {
> >        //trying with added autentication
> >        String smtphost="thednsaddress";
> >        String username="thelogginname";
> >        String password="thelogginpassword";
> >              Message message = new MimeMessage(mailSession);
> >        try{
> >        InternetAddress from = new InternetAddress("the_sender_addr");
> >        InternetAddress to = new InternetAddress("the_resiver_addr");
> >
> >        String mailer = "smtpsend";
> >        message.setHeader("X-Mailer", mailer);
> >        message.setSentDate(new Date());
> >        message.setFrom(from);
> >        message.addRecipient(Message.RecipientType.TO, to);
> >        message.setSubject("The subject");
> >        message.setText("The message");
> >             Transport tr = mailSession.getTransport("smtp");
> >        tr.connect(smtphost, username, password);
> >        //tr.connect(); //no extra params just the gbean settings
> > (host,port)
> >        message.saveChanges(); // don't forget this
> >        tr.sendMessage(message, message.getAllRecipients());
> >        tr.close();
> >        //replaced with the settup above
> >        //mailSession.getTransport("smtp");
> >        //Transport.send(message);
> >
> >        }catch(AddressException aex){
> >            logger.error("execute got a AddressException
> > "+aex.getMessage());
> >        }catch(MessagingException mex){
> >            logger.error("execute got a MessagingException
> > "+mex.getMessage(),mex);
> >        }    }
> > }
> >
> >
> > Geronimo Quartz Plan
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <jobs xmlns="http://geronimo.apache.org/xml/ns/plugins/quartz-0.2">
> >    <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
> >              <moduleId>
> >            <groupId>test</groupId>
> >            <artifactId>ReportSendJobs</artifactId>
> >        </moduleId>
> >                     <dependencies>
> >            <dependency>
> >                 <groupId>test</groupId>
> >                 <artifactId>javamail-server</artifactId>
> >            </dependency>
> >                      <dependency>
> >                 <groupId>console.dbpool</groupId>
> >                 <artifactId>MySqlDB_report_sender</artifactId>
> >             </dependency>
> >        </dependencies>               </environment>
> >      <job>
> >        <job-name>Job name</job-name>
> >        <job-class>classpath to jobb class</job-class>
> >        <cron-expression>0/30 * * * * ?</cron-expression>
> >              <resource-ref>
> >            <property>Database</property>
> >            <res-type>javax.sql.DataSource</res-type>
> >            <res-auth>Container</res-auth>
> >            <res-sharing-scope>Shareable</res-sharing-scope>
> >            <pattern>
> >                <name>MySqlDB_report_sender</name>
> >            </pattern>
> >        </resource-ref>
> >              <resource-ref>
> >            <property>MailSession</property>
> >            <res-type>javax.mail.Session</res-type>
> >            <res-auth>Container</res-auth>
> >            <res-sharing-scope>Shareable</res-sharing-scope>
> >            <pattern>
> >                <name>mail/MailSession</name>
> >            </pattern>
> >        </resource-ref>    </job> </jobs>
> >
> >
> > The "mail-server" plan (slightly moddyfied version of what I got from
> > Rick):
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
> > <dep:environment
> > xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
> >   <dep:moduleId>
> >     <dep:groupId>test</dep:groupId>
> >     <dep:artifactId>javamail-server</dep:artifactId>
> >   </dep:moduleId>
> >
> >   <dep:dependencies>
> >     <dep:dependency>
> >       <dep:groupId>geronimo</dep:groupId>
> >       <dep:artifactId>geronimo-mail</dep:artifactId>
> >       <dep:version>1.1.1</dep:version>
> >       <dep:type>jar</dep:type>
> >       <dep:import>classes</dep:import>
> >     </dep:dependency>
> >     <dep:dependency>
> >       <dep:groupId>geronimo</dep:groupId>
> >       <dep:artifactId>geronimo-javamail-transport</dep:artifactId>
> >       <dep:version>1.1.1</dep:version>
> >       <dep:type>jar</dep:type>
> >       <dep:import>classes</dep:import>
> >     </dep:dependency>
> >     <dep:dependency>
> >       <dep:groupId>geronimo</dep:groupId>
> >       <dep:artifactId>rmi-naming</dep:artifactId>
> >       <dep:type>car</dep:type>
> >     </dep:dependency>
> >   </dep:dependencies>
> >   <dep:hidden-classes/>
> >   <dep:non-overridable-classes/>
> > </dep:environment>
> >
> > <gbean name="SMTPTransport"
> > class="org.apache.geronimo.mail.SMTPTransportGBean">
> >   <attribute name="host">removed dns name</attribute>
> >   <attribute name="port">25</attribute>
> > </gbean>
> > <gbean name="mail/MailSession"
> > class="org.apache.geronimo.mail.MailGBean">
> >   <attribute name="transportProtocol">smtp</attribute>
> >   <attribute name="debug">true</attribute>
> >   <reference name="Protocols">
> >      <name>SMTPTransport</name>
> >   </reference>
> > </gbean>
> > </module>
> >
> >
> > Peter Petersson skrev:
> >> It is a remote SMTP server (in our lan) and autentication shuld not
> >> be needed from inside our LAN (I have sucsessfully accessed the SMTP
> >> server from within a vanila tomcat5 web app without autentication).
> >> Could a autentication faliur result in a NoSuchProviderException ?
> >> I have tryed setting the Transport attributes (smtphost, username,
> >> password) from within the code
> >>
> >> Transport tr = mailSession.getTransport("smtp");
> >> tr.connect(smtphost, username, password);
> >> and also tryed a GBean via the attributes (host,port).
> >> The Gbean is from a sligtly moddified version of the "example mail
> >> session" that Rick posted (he did a farly good shoot from the hip ;)).
> >>
> >> I but regardles of a lott of testing with different setups i still get
> >>
> >> javax.mail.NoSuchProviderException: Unable to locate provider for
> >> protocol: smtp
> >>        at javax.mail.Session.getProvider(Session.java:227)
> >>        at javax.mail.Session.getTransport(Session.java:336)
> >>
> >>
> >> Im testing this on a fresh install of Geronimo 1.1.1
> >>
> >> Anny suggestions ?
> >>
> >> Cheers
> >>   Peter
> >>
> >> Aaron Mulder skrev:
> >>> Does your localhost have a mail server running?  Or are you trying to
> >>> send through a remote SMTP server?  Is the mail server open or do you
> >>> need to authenticate to it?
> >>>
> >>> Thanks,
> >>>     Aaron
> >>>
> >>> On 9/29/06, Peter Petersson <peter@pmb.mine.nu> wrote:
> >>>> Hi all!
> >>>>
> >>>> I quite new to Geronimo (using 1.1.1) and have some problems geting
> >>>> mail
> >>>> to work from a geronimo-quartz job.
> >>>> As I understand it I need to set up a gbean or do some other
> >>>> configuration for javamail to work (?).
> >>>> The example i have folowed for the Quartz Scheduler Plugin over at
> >>>> http://gplugins.sourceforge.net/ have a nice setup including
> >>>> mailing (in
> >>>> the "Deployable Jobs Example" section) but it dose not go into details
> >>>> on howto set up mailing (its not the scope of the example).
> >>>>
> >>>> What do I need to do to get it to work? as it is now i get this
> >>>> exception
> >>>>
> >>>> MessagingException Unable to locate provider for protocol: smtp
> >>>>
> >>>> Anny good pointer out there to get mailing working in Geronimo ?
> >>>>
> >>>> Cheers
> >>>>   Peter
> >>>>
> >
>
>

Mime
View raw message