0
votes

I have been researching this error for a couple of days. No response on the Liferay forum (yet) and even though I have tried several different approaches, I can't figure out the true cause of the error. If I can find the cause I could probably fix it. The error is:

Caused by: java.lang.VerifyError: Bad type on operand stack_Exception Details:_ Location:_
org/bsfinternational/api/core/service/impl/EmailLocalServiceImpl.sendEmail(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V @930: invokevirtual_

Reason:_ Type 'com/sun/mail/smtp/SMTPMessage' (current frame, stack[1]) is not assignable to 'javax/mail/Message'_

Current Frame:_ bci: @930_ flags: { }_ locals: { 'org/bsfinternational/api/core/service/impl/EmailLocalServiceImpl', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', integer, 'javax/mail/Session', 'org/apache/commons/validator/routines/EmailValidator', 'de/agitos/dkim/DKIMSigner', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'com/sun/mail/smtp/SMTPMessage', integer, 'java/lang/String', 'org/bsfinternational/api/core/model/Email', '[Ljavax/mail/internet/InternetAddress;', 'java/lang/String', '[Ljava/lang/String;', 'java/util/List', '[Ljavax/mail/internet/InternetAddress;', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', integer, 'javax/mail/Transport' }_ stack: { 'javax/mail/Transport', 'com/sun/mail/smtp/SMTPMessage', '[Ljavax/mail/Address;' }_

So, I get that there is an issue with SMTPMessage not being assignable to Message but I don't know why. The research I have done seems to point to JVM differences but everything have been compiled in the same environment, as far as I know.

The actual code snippet is:

    // construct the JavaMail message using the DKIM message type from DKIM for JavaMail
        SMTPMessage msg = new SMTPDKIMMessage(session, dkimSigner);

If I try assigning SMTPDKIMMessage to the same type in the code like so:

// construct the JavaMail message using the DKIM message type from DKIM for JavaMail
        SMTPDKIMMessage msg = new SMTPDKIMMessage(session, dkimSigner);

Then the compliant is that SMTPDKIMMessage isn't assignable to Message. If I change it to Message, then it complains that SMTPDKIMMessage isn't assignable. Seems like a circle.

So, the first question here is: What is the true cause? What should I look for that is generating the error? I have compiled the DKIMforJavaMail.jar using the same IDE and compiling environment. But someone is unhappy with these assignments. What is it?

2

2 Answers

0
votes

The big question here is: How do you build, and do you have duplicate classes on the classpath. E.g. are you bundling the javax.mail classes somewhere in your plugin?

Typically, if a class is not a valid descendent of a legitimate superclass, the superclass will be available in two different flavors. That's why the error message doesn't make immediate sense, because it does only contain the name, not the difference between the actual class instances.

Inspect your plugin - which classes does it (or the jars it depends on) contain? Which is it dependent on - you mention Liferay 7, so there's a good chance that multiple versions of the underlying API are available, leading to such problems.

0
votes

I continue to take different approaches but I haven't made much headway. Yes, somewhere in the stack there is a problem. I am only using JavaMail to create and send an email from my portlet. Yeah, I know that Liferay has an implementation of JavaMail but it doesn't support DKIM. I am porting all of this code from 6.0.6 and this is the only code that I haven't been able to resolve. As far as I know, the mail.jar in the Tomcat home/lib/ext folder is what I need and lacking any other approach I copied it to my module's lib folder and included it with my other non-maven jars. I have commented out my DKIM code and just trying to get a normal, simple Javamail sending routine to work...but no luck...yet. Still trying...