0

I am trying to send an eMail with attachment, without the use of an 3rd party mailserver (like smtp.gmail.com).

Basics/Preperation

In this thread I followed the advice to construct the MimeMessage first and then send it by myMailQue.queMail(msg);.

It works fine in a test package. I get the following output on the terminal:

Jul 31, 2015 2:28:00 PM Aspirin run
INFORMATION: QueManager.run(): QueManager started.
Jul 31, 2015 2:28:01 PM Aspirin run
INFORMATION: RemoteDelivery (RemoteDelivery-1).run(): Try to give back RemoteDelivery object into the pool.

and the mail arrives after some seconds.

The Problem

When I try to use it in my OSGi framework (felix) no mail is send. There is no exception or any other information printed, even the output mentioned above!

I was not able to find a bundle version the aspirin-jar, so I converted it myself with bnd. Like this:

java -jar bnd-2.1.0.jar wrap jar/aspirin-0.8.3.jar

My Tests

With the converted jar in my bundle folder, there are no wiring-packages-issues, so it should work? Example for the issues:

Unresolved constraint in bundle edu.hm.ee.hem.validation [5]: Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=org.masukomi.aspirin.core)

My code from which I call queMail(msg) is able to call other methods of the aspirin bundle. For example I am calling the function myMailQue.getQueueSize() once before queMail(msg) and once afterwords. The results are 0 and 1, that makes sence (imo).


I am really confused by this set-up not working, especially without any Exception it's hard to understand what is going wrong

So I think the only difference between my test package and the framework, is the converted jar. Has anyone an idea how I could solve the problem?

Thank you very much in advance


P.S. This my first question here (I've read a lot ;) So if I am missing any important information or the format of my question makes it hard to understand please give me a hint.

1 Answers1

0

Like you mentioned aspirin does not seem to be prepared for OSGi. Simply wrapping a jar is not always enough to make it OSGi ready.

If you look at the Aspirin code you can see that it uses class names at some places to refer to implementation classes. In OSGi the class loaders are per bundle and only provide the packages that are made visible using Import-Package. So if you for example provide your own implementation for one of the interfaces of Aspirin and provide the class name in a config then aspirin will not be able to load such a class in its own classloader in OSGi.

The solution is to either have API methods that allow to set a Class instead of a class name or allow the user to provide the class loader that knows about the class in addition to the class name.

So probably you have to make the author of aspirin aware of your situation and ask him to make the code OSGi compatible.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64