Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - include referenced library in jar

I have OSGi bundle for sending mails, so it's using com.sun.smtp package from mail-1.4.jar. But OSGi service do not have access to this jar.

Can you help me, how to configure Maven POM file so mail-1.4.jar will be included in my bundle jar so OSGi service could use it?

EDIT

Error is:
javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp

like image 472
Michał Herman Avatar asked Dec 04 '25 14:12

Michał Herman


1 Answers

I would advise to not include the mail jar in your bundle. The better way is to simply install the mail.jar in the osgi runtime.

You have to make sure you have two things in place to make this work:

  1. Make sure you import the required package in the manifest of your own bundle. Normally simply using the maven bundle plugin with defaults does this but you should check the resulting Manifest
  2. Deploy the mail.jar into your OSGi runtime. If you are using apache karaf then simply do: mvn install -s mvn:javax.mail/mail/1.4.4 if not then the jar below should help. It contains a correct Manifest file for OSGi deployment http://search.maven.org/#artifactdetails|javax.mail|mail|1.4.4|jar
like image 146
Christian Schneider Avatar answered Dec 07 '25 02:12

Christian Schneider



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!