Expand my Community achievements bar.

java.lang.LinkageError: javax/mail/Session

Avatar

Level 3

In our AEM Forms 6.3 J2EE environment we are using the LiveCycle EmailService succesfully.

Now, for another process, we want to use the Day CQ Mail Service also.

After submitting the adaptive form to the com.day.cq.mailer.DefaultMailService  we get an error:

Error during include of component '/libs/fd/af/components/guideContainerWrapper'

Error Message:

java.lang.LinkageError: javax/mail/Session

It seems there is a conflict with the two different EmailSerivces?

10 Replies

Avatar

Level 10

Email in AEM is typically used for AEM Workflows.  Looks like you want to send an email when a form is submitted, If so, develop a custom AEM service that uses Java MAIL API to send emails.

Avatar

Level 3

Thanks for the answers.

This means that in a JEE environment, the built-in OSGI mail services can not be used; instead, separate components have to be developed?

Jan

Avatar

Level 2

Hi Scott,

I've written my own mail service as suggested, using the JavaMail API, but I still get the error:

java.lang.LinkageError: Failed to link javax/mail/Session (Module "javax.mail.api:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: C:\Adobe\Adobe_Experience_Manager_Forms\jboss\modules,C:\Adobe\Adobe_Experience_Manager_Forms\jboss\modules\system\layers\base\.overlays\layer-base-jboss-eap-7.0.6.CP,C:\Adobe\Adobe_Experience_Manager_Forms\jboss\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/mail/Session" 

I suspect it's because JBoss is supplying its own javax.mail.api modules (once in system/layers/base, once in the layer-base-jboss-eap-7.0.6.CP overlay). What can I do to fix this?

Avatar

Level 10

This confirms that there is an issue in your environment. The Java MAIL API should successfully work within an OSGi bundle using MessageServiceGaetway. I will post a short video tomorrow of this working in the AEM environment. If you cannot reproduce the video, we will get cust care involved.

Avatar

Level 2

Thanks.

The custom mail service works locally and on a non-JBoss deployment; it's only on the JBoss box it fails.

Avatar

Level 2

Hi Scott,

Any updates? I've tried changing around my pom.xml dependency settings, but nothing has made any difference.

The error I'm getting now is slightly different (and much less helpful) than before:

java.lang.LinkageError: javax/mail/Session

at com.sun.mail.util.PropUtil.getBooleanSessionProperty(PropUtil.java:106)

at javax.mail.internet.MimeMessage.initStrict(MimeMessage.java:315) [javax.mail:1.5.0.b01]

at javax.mail.internet.MimeMessage.<init>(MimeMessage.java:193) [javax.mail:1.5.0.b01]

The code in question:

            // Get system properties

            Properties properties = System.getProperties();

            properties.setProperty("mail.smtp.host", smtpHost);

            properties.setProperty("mail.smtp.port", smtpPort);

            properties.setProperty("mail.smtp.submitter", smtpUser);

            properties.setProperty("mail.smtp.auth", "true");

            // Get the authenticated Session object.

            Session session = Session.getInstance(properties,

                    new javax.mail.Authenticator() {

                        protected PasswordAuthentication getPasswordAuthentication() {

                            return new PasswordAuthentication(

                                    smtpUser,

                                    smtpPassword);

                        }

                    });

            // Create a default MimeMessage object.

            MimeMessage message = new MimeMessage(session);

Avatar

Employee Advisor

I would like to test your code on a Jboss instance, can you please share the collateral's and the step to run the code?

-Mayank

Avatar

Level 2

You don't need anything special to reproduce this. Just send email from AEM on a JBoss instance.

Avatar

Employee Advisor

Hi,

I think there is another thread for a similar query, the answer posted By Scott and Kevin is correct(JBoss modules causing LinkageError ).

When AEM is deployed on an Application Server then the Day CQ Mail Service javax.mail bundle needs to be replaced because these Application Server come with their own javax.mail packages, and AEM should use these instead of the ones provided by the bundle.

To do so one needs to create a javax.mail fragment bundle as described in:

http://helpx.adobe.com/experience-manager/kb/CreatingExtension.html

Day CQ Mail Service does not work on AEM Forms JEE

Also, what I could check internally this has been left for developer to take care and would not be done from the product side.