Have a look at servicemix bundles:

http://repo2.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.javax.mail/1.4.1_2/org.apache.servicemix.bundles.javax.mail-1.4.1_2.jar

It has been modified to work in OSGi.

On Thu, Mar 18, 2010 at 11:38, Alexander Blotny <
[email protected]> wrote:

> Hi,
>
> I am trying to use commons-email-1.2 with apache Felix.
> I have started the bundle mail-1.4.jar (including javamail) because
> commons-email uses this library. Then I am starting commons-email and there
> are no errors.
>
> A third bundle is accessing the SimpleEmail class of commons-email and
> sends
> a mail.
> I get following error:
>
> org.apache.commons.mail.EmailException: Unable to locate provider for
> protocol: pop3
>    at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1111)
>    at org.apache.commons.mail.Email.send(Email.java:1162)
>    at
>
> de.fhg.fokus.ngni.xposer.see.service.email.impl.EmailImpl.send(EmailImpl.jav
> a:80)
>    at
>
> de.fhg.fokus.ngni.xposer.see.service.email.impl.EmailImpl.send(EmailImpl.jav
> a:33)
>     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
>
> de.fhg.fokus.ngni.xposer.see.bundle.BundleEventHandler$MyTimerTask.run(Bundl
> eEventHandler.java:164)
>    at java.util.TimerThread.mainLoop(Timer.java:512)
>    at java.util.TimerThread.run(Timer.java:462)
> Caused by: javax.mail.NoSuchProviderException: Unable to locate provider
> for
> protocol: pop3
>    at javax.mail.Session.getProvider(Session.java:229)
>    at javax.mail.Session.getStore(Session.java:270)
>    at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1105)
>
>
> I guess that some properties cannot be loaded because of the classloading
> in
> OSGi but how can I change that?
>
> The source code is:
>
>        smtpHost = MailSettings.smtpHost;        userName =
> MailSettings.smtpUsername;        pw = MailSettings.smtpPassword;
> emailAddress = MailSettings.fromAddress;        pop3Host =
> MailSettings.pop3Host;                        toAddress = emailAddress;
> try {            SimpleEmail email=new SimpleEmail();
> email.setHostName(smtpHost);            email.setAuthentication(userName,
> pw);            email.setFrom(emailAddress, user);
> email.addTo(toAddress);
> email.setPopBeforeSmtp(true, pop3Host, userName, pw);
> email.setSubject(subject);            email.setMsg(message);
> email.send();        } catch (EmailException e) {
> e.printStackTrace();            return false;        }
>
> Thx,
> Alex
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Reply via email to