You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Alexander Blotny <Al...@fokus.fraunhofer.de> on 2009/07/10 14:03:46 UTC
NoClassDefFoundError
Hi,
I have a problem using Apache Felix.
A class can not be loaded but it is imported and exported correctly, so the
ClassLoader should find it. Maybe someone has an idea how I can find out
what the problem is?
The log:
ERROR: Error starting file:test_bundles/sipsee.jar
(org.osgi.framework.BundleException: Activator start error in bundle sipsee
[10].)
java.lang.NoClassDefFoundError: javax/servlet/ServletException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at
org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.findCla
ss(ModuleImpl.java:1556)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
gation(ModuleImpl.java:562)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
a:59)
at
org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
ss(ModuleImpl.java:1446)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(Modu
leImpl.java:481)
at
org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:108)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.searchImports(ModuleImpl.
java:1184)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
gation(ModuleImpl.java:557)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
a:59)
at
org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
ss(ModuleImpl.java:1446)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at
de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.initApplicationContext(S
ipSeeServletSipContext.java:915)
at
de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.<init>(SipSeeServletSipC
ontext.java:250)
at
de.fhg.fokus.sipsee.servlet.sip.SipApplicationContext.<init>(SipApplicationC
ontext.java:161)
at
de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContext.<init>(SipSe
eIMSApplicationContext.java:92)
at
de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContextFactory.creat
eContext(SipSeeIMSApplicationContextFactory.java:53)
at
de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:669)
at
de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
1460)
at
de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:695)
at
de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
1473)
at
de.fhg.fokus.scxml.impl.sipsee.SipseeActivator.start(SipseeActivator.java:30
)
at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav
a:589)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1458)
at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
at java.lang.Thread.run(Thread.java:619)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: NoClassDefFoundError
Posted by "Richard S. Hall" <he...@ungoverned.org>.
You need to give us more information, such as the manifests of the
bundles involved and perhaps a "jar tf" of them as well.
-> richard
On 7/10/09 8:03 AM, Alexander Blotny wrote:
> Hi,
>
> I have a problem using Apache Felix.
> A class can not be loaded but it is imported and exported correctly, so the
> ClassLoader should find it. Maybe someone has an idea how I can find out
> what the problem is?
>
> The log:
>
> ERROR: Error starting file:test_bundles/sipsee.jar
> (org.osgi.framework.BundleException: Activator start error in bundle sipsee
> [10].)
> java.lang.NoClassDefFoundError: javax/servlet/ServletException
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.findCla
> ss(ModuleImpl.java:1556)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
> gation(ModuleImpl.java:562)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
> a:59)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
> ss(ModuleImpl.java:1446)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(Modu
> leImpl.java:481)
> at
> org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:108)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.searchImports(ModuleImpl.
> java:1184)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
> gation(ModuleImpl.java:557)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
> a:59)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
> ss(ModuleImpl.java:1446)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> at
> de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.initApplicationContext(S
> ipSeeServletSipContext.java:915)
> at
> de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.<init>(SipSeeServletSipC
> ontext.java:250)
> at
> de.fhg.fokus.sipsee.servlet.sip.SipApplicationContext.<init>(SipApplicationC
> ontext.java:161)
> at
> de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContext.<init>(SipSe
> eIMSApplicationContext.java:92)
> at
> de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContextFactory.creat
> eContext(SipSeeIMSApplicationContextFactory.java:53)
> at
> de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:669)
> at
> de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
> 1460)
> at
> de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:695)
> at
> de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
> 1473)
> at
> de.fhg.fokus.scxml.impl.sipsee.SipseeActivator.start(SipseeActivator.java:30
> )
> at
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav
> a:589)
> at org.apache.felix.framework.Felix.startBundle(Felix.java:1458)
> at
> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
> at
> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
> at java.lang.Thread.run(Thread.java:619)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: NoClassDefFoundError
Posted by Alexander Blotny <Al...@fokus.fraunhofer.de>.
Thanks.
I tried it with the current trunk and it works.
Am 10.07.09 14:23 schrieb "Karl Pauls" unter <ka...@gmail.com>:
> Can you try again with the current trunk?
>
> regards,
>
> Karl
>
> On Fri, Jul 10, 2009 at 2:03 PM, Alexander
> Blotny<Al...@fokus.fraunhofer.de> wrote:
>> Hi,
>>
>> I have a problem using Apache Felix.
>> A class can not be loaded but it is imported and exported correctly, so the
>> ClassLoader should find it. Maybe someone has an idea how I can find out
>> what the problem is?
>>
>> The log:
>>
>> ERROR: Error starting file:test_bundles/sipsee.jar
>> (org.osgi.framework.BundleException: Activator start error in bundle sipsee
>> [10].)
>> java.lang.NoClassDefFoundError: javax/servlet/ServletException
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.findCla
>> ss(ModuleImpl.java:1556)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
>> gation(ModuleImpl.java:562)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
>> a:59)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
>> ss(ModuleImpl.java:1446)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(Modu
>> leImpl.java:481)
>> at
>> org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:108)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl.searchImports(ModuleImpl.
>> java:1184)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
>> gation(ModuleImpl.java:557)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
>> a:59)
>> at
>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
>> ss(ModuleImpl.java:1446)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>> at
>> de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.initApplicationContext(S
>> ipSeeServletSipContext.java:915)
>> at
>> de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.<init>(SipSeeServletSipC
>> ontext.java:250)
>> at
>> de.fhg.fokus.sipsee.servlet.sip.SipApplicationContext.<init>(SipApplicationC
>> ontext.java:161)
>> at
>> de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContext.<init>(SipSe
>> eIMSApplicationContext.java:92)
>> at
>> de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContextFactory.creat
>> eContext(SipSeeIMSApplicationContextFactory.java:53)
>> at
>> de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:669)
>> at
>> de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
>> 1460)
>> at
>> de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:695)
>> at
>> de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
>> 1473)
>> at
>> de.fhg.fokus.scxml.impl.sipsee.SipseeActivator.start(SipseeActivator.java:30
>> )
>> at
>> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav
>> a:589)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1458)
>> at
>> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>> at
>> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>> at java.lang.Thread.run(Thread.java:619)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: NoClassDefFoundError
Posted by Karl Pauls <ka...@gmail.com>.
Can you try again with the current trunk?
regards,
Karl
On Fri, Jul 10, 2009 at 2:03 PM, Alexander
Blotny<Al...@fokus.fraunhofer.de> wrote:
> Hi,
>
> I have a problem using Apache Felix.
> A class can not be loaded but it is imported and exported correctly, so the
> ClassLoader should find it. Maybe someone has an idea how I can find out
> what the problem is?
>
> The log:
>
> ERROR: Error starting file:test_bundles/sipsee.jar
> (org.osgi.framework.BundleException: Activator start error in bundle sipsee
> [10].)
> java.lang.NoClassDefFoundError: javax/servlet/ServletException
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.findCla
> ss(ModuleImpl.java:1556)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
> gation(ModuleImpl.java:562)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
> a:59)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
> ss(ModuleImpl.java:1446)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(Modu
> leImpl.java:481)
> at
> org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:108)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.searchImports(ModuleImpl.
> java:1184)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDele
> gation(ModuleImpl.java:557)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.jav
> a:59)
> at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadCla
> ss(ModuleImpl.java:1446)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> at
> de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.initApplicationContext(S
> ipSeeServletSipContext.java:915)
> at
> de.fhg.fokus.sipsee.servlet.SipSeeServletSipContext.<init>(SipSeeServletSipC
> ontext.java:250)
> at
> de.fhg.fokus.sipsee.servlet.sip.SipApplicationContext.<init>(SipApplicationC
> ontext.java:161)
> at
> de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContext.<init>(SipSe
> eIMSApplicationContext.java:92)
> at
> de.fhg.fokus.sipsee.servlet.sip.ims.SipSeeIMSApplicationContextFactory.creat
> eContext(SipSeeIMSApplicationContextFactory.java:53)
> at
> de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:669)
> at
> de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
> 1460)
> at
> de.fhg.fokus.sipsee.SipSeeServer.addApplication(SipSeeServer.java:695)
> at
> de.fhg.fokus.sipsee.ims.SipSeeIMSServer.addApplication(SipSeeIMSServer.java:
> 1473)
> at
> de.fhg.fokus.scxml.impl.sipsee.SipseeActivator.start(SipseeActivator.java:30
> )
> at
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav
> a:589)
> at org.apache.felix.framework.Felix.startBundle(Felix.java:1458)
> at
> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
> at
> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
> at java.lang.Thread.run(Thread.java:619)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
--
Karl Pauls
karlpauls@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: commons-mail with apache felix
Posted by Guillaume Nodet <gn...@gmail.com>.
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 <
Alexander.Blotny@fokus.fraunhofer.de> 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
Re: commons-mail with apache felix
Posted by Alexander Blotny <Al...@fokus.fraunhofer.de>.
I forgot to say that I am working with reflection for getting the class that
implements the send method in the third bundle.
I tried it now without reflection and it works.
Has anyone experience with the side effects of using reflection in the OSGi
environment? Maybe it is a bad idea to use it at all. What I want to achieve
is a dynamic environment in which users can add bundles with certain
functionality (methods). These methods can be combined with an orchestration
language. And for calling a single method I am using reflection as I am only
aware of method names and the belonging classes.
Thx
Alex
Am 18.03.10 11:38 schrieb "Alexander Blotny" unter
<Al...@fokus.fraunhofer.de>:
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
commons-mail with apache felix
Posted by Alexander Blotny <Al...@fokus.fraunhofer.de>.
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