bcgit / bc-java

Bouncy Castle Java Distribution (Mirror)
https://www.bouncycastle.org/java.html
MIT License
2.22k stars 1.1k forks source link

bc-jmail Bundle does not import jakarta.mail packages where bc-mail imports javax.mail packages #1672

Open precoder opened 1 month ago

precoder commented 1 month ago

Hello,

I am trying to move from javax.mail to jakarta.mail thanks to owner of Java Trademark. I tried to replace the bc-mail with bc-jmail but I get the following exception:

Caused by: java.lang.ClassNotFoundException: jakarta.mail.MessagingException not found by bcjmail [41]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1591)
        at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1976)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        ... 15 more

I have seen that bc-jmail Bundle does not import jakarta.mail packages where bc-mail imports javax.mail packages. I have following packages on the runtime:

38|Active     |    3|bcpkix (1.78.1)|1.78.1
39|Active     |    3|bcprov (1.78.1)|1.78.1
40|Active     |    3|bcpg (1.78.1)|1.78.1
41|Active     |    3|bcjmail (1.78.1)|1.78.1
42|Active     |    3|bcutil (1.78.1)|1.78.1

Can you fix the error in the bc-jmail Bundle and import jakarta.mail packages, please?

precoder commented 1 month ago

I guess this Import was wrong in the 1.78.1 Version but fixed on the main by this change, which is not yet released: https://github.com/bcgit/bc-java/commit/0b17828e62a8f7510978d167fd7d9a62109f249d#diff-59f78c5fd86156da09a8e5a69c77a80cbfcf4b7ffb5a20155a927fd059621512

1.78.1 Version without Jakarta Imports: https://github.com/bcgit/bc-java/blob/1.78.1/jmail/build.gradle#L87

Latest on main Version with Jakarta Imports: https://github.com/bcgit/bc-java/blob/main/jmail/build.gradle#L88

Are there any snapshots or daily/weekly builds which we can use?

dghgit commented 1 month ago

Try what's on https://www.bouncycastle.org/betas

precoder commented 1 month ago

I had tried Beta from Apr 13, 2024 but it was still not containing any jakarta import statement in the META-INF/MANIFEST.MF and commit I found seems later than Apr 13, 2024. Currently Betas Page is giving 404 when I try the link: https://downloads.bouncycastle.org/betas/bcjmail-jdk18on-1.78.1.jar

If there are new betas building then I can try them.

dghgit commented 1 month ago

Might be a caching issue. The current page has 1.79-SNAPSHOT in it.

precoder commented 1 month ago

Oh yes, now I get it 👍

precoder commented 1 month ago

Thank you very much, it seems like now it is working as expected.

On the pure OSGI setup I still get an error due to MailCap can not load MIME Parsers but it is probably an error on the jakarta.activation side, which I already have a workaround. Bouncy Castle part is working as expected.