Really weird error using sendMail action with attachment

I got this really strange error when calling the sendMail action with an attachment. I’ve see my fair share of rule errors before, but this one is a real beauty.

2019-01-05 20:21:47.282 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 
'TestRuleOn': loader constraint violation: when resolving method
 "javax.mail.BodyPart.setDataHandler(Ljavax/activation/DataHandler;)V" the class 
loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) of the 
current class, org/apache/commons/mail/MultiPartEmail, and the class 
loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) for 
the method's defining class, javax/mail/Part, have different Class objects for the 
type javax/activation/DataHandler used in the signature

The statement looks like this, and has worked for a really, really long time.

sendMail("my@email.address", "Email subject", "Email body", "file:///path/to/image.jpg")


sendMail("my@email.address", "Email subject", "Email body", "")

I’m on build 1484. Does anyone have any idea what would cause this?

Note: It works file when not attaching anything, for example

sendMail("my@email.address", "Email subject", "Email body")
1 Like

Possibly related, this thread says that the javax.activation package is deprecated and many of its methods are disabled by default in Java 9.

Are you, mayhap, using Java 9?

I’m on Java 8, and that has not changed in a long time.

Could it be a classpath issue, overlapping jars? I send mail with attachments in Jython (OH 2.4 final), and it works fine.

I dunno. Nothing has changed in my setup other than running a recent snapshot. I tried it on another system running build 1484 and I’m getting the same error.

Googling around, I found this, which suggests it’s a dependency issue.

Sounds like a snapshot bug then. I suppose you would only know for sure if it works again when you roll back to an older build.

Yeah, possibly, although it’s unclear what would’ve changed to cause this.

I’m gonna roll back to 1458 (which is a 2.4.0 build) to see what happens.

Yep, it works fine on 1458, so it appears to be a snapshot bug.


1 Like

@vzorglub This really isn’t solved, since the issue remains in recent snapshot releases. Reverting to an old version is just a workaround.

Yes sorry, I read the Snapshot versions the wrong way around…

I noticed this today too.
The older version gave other problems for me (which I don’t remember anymore)

Anyone have an idea what caused the snapshot problem. (I assume we need to know that before anyone can think of solving it)

Here’s the issue, which contains the explanation of the problem.

1 Like


As you can see on the github, this bug should be solved in the last snapshot.