HI MIchal,
i tried the instructions at this link you suggested below but i am getting errors- i am wondering if it has to do with the OR 2.6 beta with new drools version or Java version 8
https://openremote.github.io/archive-dotorg/forums/22872974.html
below is the copy of the rule and the error messages- i hope its something simple Any help is greatly appreciated.
I have 2 drl files in the rules folder - one with working set of rules and other with the rule for email for testing.
//trial email with orcbeta2.6
package org.openremote.controller.model.event
global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
import org.openremote.controller.protocol.Event;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
// email notifications
rule âSend mailâ
when
Switch ( source == âSend mail sensorâ, value == âonâ)
then
execute.command (âSend mail OFFâ);
final String username = âorc@gmail.comâ;
final String password = âmypasswordâ;
Properties props = new Properties();
props.put(âmail.smtp.hostâ, âsmtp.gmail.comâ);
props.put(âmail.smtp.socketFactory.portâ, â465â);
props.put(âmail.smtp.socketFactory.classâ,âjavax.net.ssl.SSLSocketFactoryâ);
props.put(âmail.smtp.authâ, âtrueâ);
props.put(âmail.smtp.portâ, â465â);
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(âorc@gmail.comâ));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(âorc@gmail.comâ));
message.setSubject(âtrialâ);
message.setText(âtriall triallâ);
Transport.send(message);
System.out.println(âMail sentâ);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
end
ERROR messages:
DEBUG 2017-03-12 22:16:12,460 : Starting event processor: Drools Rule Engine
DEBUG 2017-03-12 22:16:12,583 : Adding Rule âtrial_modeler_rules.drlââŚ
DEBUG 2017-03-12 22:16:12,584 : Adding Rule âmodeler_rules.drlââŚ
INFO 2017-03-12 22:16:21,149 : Starting device discovery serviceâŚ
DEBUG 2017-03-12 22:16:21,150 : checking for discovered devicesâŚ
ERROR 2017-03-12 22:16:22,581 : Rule definition âtrial_modeler_rules.drlâ could not be deployed. See errors below.
ERROR 2017-03-12 22:16:22,584 : Rule Compilation error Only a type can be imported. javax.mail.PasswordAuthentication resolves to a package
Only a type can be imported. javax.mail.internet.InternetAddress resolves to a package
Only a type can be imported. javax.mail.Message resolves to a package
Only a type can be imported. javax.mail.Transport resolves to a package
Only a type can be imported. javax.mail.MessagingException resolves to a package
Only a type can be imported. javax.mail.Session resolves to a package
Only a type can be imported. javax.mail.internet.MimeMessage resolves to a package
Session cannot be resolved to a type
Session cannot be resolved
javax.mail.Authenticator cannot be resolved to a type
Message cannot be resolved to a type
MimeMessage cannot be resolved to a type
InternetAddress cannot be resolved to a type
Message.RecipientType.TO cannot be resolved to a type
InternetAddress cannot be resolved
Transport cannot be resolved
MessagingException cannot be resolved to a type
ERROR 2017-03-12 22:16:22,586 : Error importing : âjavax.mail.PasswordAuthenticationâ
ERROR 2017-03-12 22:16:22,586 : Error importing : âjavax.mail.internet.MimeMessageâ
ERROR 2017-03-12 22:16:22,587 : Error importing : âjavax.mail.MessagingExceptionâ
ERROR 2017-03-12 22:16:22,588 : Error importing : âjavax.mail.internet.InternetAddressâ
ERROR 2017-03-12 22:16:22,588 : Error importing : âjavax.mail.Sessionâ
ERROR 2017-03-12 22:16:22,589 : Error importing : âjavax.mail.Transportâ
ERROR 2017-03-12 22:16:22,590 : Error importing : âjavax.mail.Messageâ
INFO 2017-03-12 22:16:24,056 : Added rule definition âmodeler_rules.drlâ to knowledge.
INFO 2017-03-12 22:16:33,971 : Started event processor : Drools Rule Engine