You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing OSGI package-exports from core-module #288
Thank you for providing OSGI-headers in simple-java-mail to make it deployable as bundle! Unfortunately I get some trouble when trying to deploy it, together with it's required OSGI-bundles (core-module, jakarta.mail, jakarta.activation, emailaddress-rfc2822, jetbrains-runtime-annotations). I get some errors in the OSGI console (specifically, I'm using Felix in Apache Sling ):
org.simplejavamail.api.internal.authenticatedsockssupport.socks5server -- Cannot be resolved
org.simplejavamail.api.internal.batchsupport -- Cannot be resolved
org.simplejavamail.api.internal.clisupport.model -- Cannot be resolved
org.simplejavamail.api.internal.outlooksupport.model -- Cannot be resolved
org.simplejavamail.api.internal.smimesupport.builder -- Cannot be resolved
org.simplejavamail.api.internal.smimesupport.model -- Cannot be resolved
org.simplejavamail.internal.util -- Cannot be resolved
It seems all these packages are contained in the core-module, which was successfully deployed and active. But it does not export those: it's exported packages are
To be honest I know next to nothing about OSGI and the only reason the headers you mention are there is because of pull request #146. So if you know how to fix this, by all means, open a pull request.
I stumbled upon the same problem, while trying to use simple-java-mail within an Apache Karaf Runtime Environment. Exports for internal packages are missing. I guess they're not exported autoamtically, because of the ".internal." part in the package names. It's best practice to not export internal packages and the maven-bundle-plugin perhaps follow this practice if running with defaults.
The whole problem results from class loader isolation in OSGi. Every "bundle" (a deployable .jar with bundle information added to its MANIFEST.MF) resides in its own class loader and lookups to other bundles are controlled by package export/import declarations and dynamic dependency injection. Splitting a project in multiple modules whereas not providing these declaration makes it nearly impossible to use this project without restructuring the project.
Therefore I created a simple test project simple-java-mail-osgi.zip to re-bundle all needed simple-java-mail modules into one osgi bundle with complete package export/import declarations. There are just some extra instructions for the maven-bundle-plugin needed to achieve this.
While inspecting the resulting artifact, I recognized an auto generated import declaration org.jacoco.agent.rt.internal_c13123e alongside some other requirements and thought they came from some "auto import" magic and prohibited their creation by adding it to the maven-bundle-plugin instructions with a leading ! in front of it.
The bundle deployed and resolved straightforward and I start trying to use it. But when trying to compose an email via EmailPopulatingBuilder emailBuilder = EmailBuilder.startingBlank();
the runtime crashes resulting in a java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_c13123e/Offline (Stacktrace attached)
Why is simple-java-mail relying on the jacoco offline agent during runtime? Is this a result of the jacoco instrument usage?
I hope someone could check my attached solution and acknowledges the results. Thanks!
It doesn't rely on it in runtime, not sure why you get that result (did you locally build Simple Java Mail and do an mvn install with that?). For actual deploys jacoco is skipped altogether, there really should be no trace of Jacoco once distributed. This is the deploy command used in the CircleCI pipeline, on a clean filesystem (so no old build results tainting the release, aside from the mvn clean being run):
The project packages fine for me but I have no idea how to test this and to reproduce your problem. Perhaps you can have another look with a later version (I just released 6.7.5)? That would be much appreciated
Activity
[-]Too many packages marked as required in OSGI headers[/-][+]Missing OSGI package-exports from core-module[/+]bbottema commentedon Aug 21, 2020
To be honest I know next to nothing about OSGI and the only reason the headers you mention are there is because of pull request #146. So if you know how to fix this, by all means, open a pull request.
grueneerle commentedon Nov 9, 2020
Hi,
I stumbled upon the same problem, while trying to use simple-java-mail within an Apache Karaf Runtime Environment. Exports for internal packages are missing. I guess they're not exported autoamtically, because of the ".internal." part in the package names. It's best practice to not export internal packages and the maven-bundle-plugin perhaps follow this practice if running with defaults.
The whole problem results from class loader isolation in OSGi. Every "bundle" (a deployable .jar with bundle information added to its MANIFEST.MF) resides in its own class loader and lookups to other bundles are controlled by package export/import declarations and dynamic dependency injection. Splitting a project in multiple modules whereas not providing these declaration makes it nearly impossible to use this project without restructuring the project.
Therefore I created a simple test project simple-java-mail-osgi.zip to re-bundle all needed simple-java-mail modules into one osgi bundle with complete package export/import declarations. There are just some extra instructions for the maven-bundle-plugin needed to achieve this.
While inspecting the resulting artifact, I recognized an auto generated import declaration
org.jacoco.agent.rt.internal_c13123ealongside some other requirements and thought they came from some "auto import" magic and prohibited their creation by adding it to the maven-bundle-plugin instructions with a leading!in front of it.The bundle deployed and resolved straightforward and I start trying to use it. But when trying to compose an email via
EmailPopulatingBuilder emailBuilder = EmailBuilder.startingBlank();the runtime crashes resulting in a
java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_c13123e/Offline(Stacktrace attached)Why is simple-java-mail relying on the jacoco offline agent during runtime? Is this a result of the jacoco
instrumentusage?I hope someone could check my attached solution and acknowledges the results. Thanks!
Kind regards,
Rene Greuel
Stacktrace: stacktrace.txt
bbottema commentedon Dec 26, 2021
It doesn't rely on it in runtime, not sure why you get that result (did you locally build Simple Java Mail and do an
mvn installwith that?). For actual deploys jacoco is skipped altogether, there really should be no trace of Jacoco once distributed. This is the deploy command used in the CircleCI pipeline, on a clean filesystem (so no old build results tainting the release, aside from the mvn clean being run):mvn -s .circleci/maven-release-settings.xml clean deploy -DdeployAtEnd=true -DperformRelease=true -DskipTests -Dspotbugs.skip=true -Denforcer.skip=true -Djacoco.skip=trueThe project packages fine for me but I have no idea how to test this and to reproduce your problem. Perhaps you can have another look with a later version (I just released 6.7.5)? That would be much appreciated
bbottema#288. Fix core-module osgi headers
bbottema#288. Add Karaf feature
bbottema#288. Fix core-module osgi headers
bbottema#288. Add Karaf feature
bbottema#288. Add Karaf feature
#288: Added missing project upkeep
bbottema commentedon Apr 15, 2023
Fix graciously provided by @jmylly. Released in v8.1.0