Maven - include the help library in the jar

I have an OSGi package to send letters, so it uses the com.sun.smtp package from mail-1.4.jar. But the OSGi service does not have access to this bank.

Can you help me how to configure the Maven POM file so that mail-1.4.jar will be included in my package so that the OSGi service can use it?

EDIT

Error:
javax.mail.NoSuchProviderException: cannot find provider for protocol: smtp

+4
source share
3 answers

I would advise against including the postal bank in my kit. It is best to just install mail.jar at runtime osgi.

You need to make sure that you have two things to do this job:

  • Be sure to import the required package into the manifest of your own package. Usually just using the maven bundle plugin with default settings does this, but you should check the resulting Manifest
  • Deploy mail.jar to the OSGi runtime. If you use apache karaf, just do: mvn install -s mvn: javax.mail / mail / 1.4.4, if not, then the jar below should help. It contains the correct manifest file for OSGi deployment http://search.maven.org/#artifactdetails|javax.mail|mail|1.4.4|jar
+2
source

Try adding this code to your pom.xml

<dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4</version> </dependency> 

or

 <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-email</artifactId> <version>1.2</version> </dependency> 

it can help you!

+3
source

One fine day, I came across the same / similar situation. Try the following:

Add the lines below to the list of dependencies:

 <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.1</version> </dependency> 

Hope this helps

+2
source

All Articles