JBoss modules causing LinkageError

Avatar

Avatar
Validate 1
Level 1
adamp25373672
Level 1

Likes

0 likes

Total Posts

10 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
adamp25373672
Level 1

Likes

0 likes

Total Posts

10 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
adamp25373672
Level 1

16-08-2018

java.lang.LinkageError: loader constraint violation: when resolving method "com.sun.mail.util.PropUtil.getBooleanSessionProperty(Ljavax/mail/Session;Ljava/lang/String;Z)Z" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) of the current class, javax/mail/internet/MimeMessage, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the method's defining class, com/sun/mail/util/PropUtil, have different Class objects for the type javax/mail/Session used in the signature

I have a custom email service that uses the JavaMail API. On a non-JBoss instance, it works fine. On JBoss, it runs into the LinkageError above.

I can't resolve the LinkageError through normal channels, because a critical class is not loading in the usual way:

!! com.sun.mail.util,version=1.5.0 -- Overwritten by Boot Delegation

The JavaMail bundle exports javax.mail and com.sun.mail.util, but the latter is being overwritten by boot delegation and picking up the JBoss module instead, which has its own class loader.

I am not the first to experience this -- see How to debug LinkageError? , Triggering Assets notifications on AEM Forms(JEE) environment -- but I have yet to find an answer for this. It seems that this issue is consistently triggered by using JavaMail (or GatewayMessageService, or any other JavaMail wrapper) on the JBoss turnkey installation.

How can I change the class loader handling to resolve the LinkageError?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 5
Employee
kjaeggin
Employee

Likes

17 likes

Total Posts

110 posts

Correct reply

11 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile

Avatar
Give Back 5
Employee
kjaeggin
Employee

Likes

17 likes

Total Posts

110 posts

Correct reply

11 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile
kjaeggin
Employee

17-08-2018

I believe you might be referring to a known issue on JEE instances of AEM Forms, which tries to use java mail in OSGi contexts. There are two instances of the javax.mail classes (one provide by AEM, and one provided by Jboss), so sending mail from adaptive forms, etc. will not work due to a class conflict. In order to resolve this you will need to generate a new bundle and replace the existing one. There is a KB article here on how you might resolve this at  [1].

[1] Day CQ Mail Service does not work on AEM Forms JEE

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 1
adamp25373672
Level 1

Likes

0 likes

Total Posts

10 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
adamp25373672
Level 1

Likes

0 likes

Total Posts

10 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
adamp25373672
Level 1

17-08-2018

I was able to get email working on JBoss by moving javax.mail.*, com.sun.mail.*, and most of javax.activation.* and com.sun.activation.* into our project, completely removing our dependency on the conflicted packages. While far from ideal, this unblocked a critical feature.

I'd still be interested to hear the proper solution for this issue.

Avatar

Avatar
Validate 1
Level 1
adamp25373672
Level 1

Likes

0 likes

Total Posts

10 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
adamp25373672
Level 1

Likes

0 likes

Total Posts

10 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
adamp25373672
Level 1

16-08-2018

I'm not familiar with JBoss. I don't understand the instructions in that link. Which WEB-INF does it mean?

This is a turnkey AWS JBoss AEM Forms box. I tried removing the javax.mail module from JBoss, but JBoss would not start without it.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

16-08-2018