Cant get javax.mail.Session to work? (Groovy Datasource or ConfigSource)
Last week or so I asked a question about using groovy to send emails, and I was pointed to some datasources such as email_TransitTime and etc, to use as a template. I’m just getting a chance to look at that this week. And I hit a snag, and I’m not sure if this is user error or something else.
I snagged the code for email_TransitTime and I did what I always do, which is to strip the code down to just the most minimal thing for object creation or for calling the classes etc that I see used, and I immediately hit the problem that the LM Groovy script always tells me:
Here is the code I’m using, this is literally the entirety of the datasource code for now, and I literally just did the imports related to mail that email_TransitTime uses, and then just as that code does, I snag the properties and then try to make a call, without defining anything etc.
import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;
//mail?
import javax.mail.*
import javax.mail.internet.*
import javax.mail.search.*
//import javax.mail.Session
//smtpProps.put("mail.smtp.port", "25");
def smtpProps = System.getProperties();
def smtpSession = Session.getInstance(smtpProps, null);
println 0;
return 0;
So I poked around online for just java and groovy use of javax.mail.Session and I found some similar instances of people having a similar error and they fixed it by putting some other java file somewhere, but I cant control all of this obviously on the LM platform. I guess.
But what I’m getting at is that I cant even interact with javax.mail.Session at all, from playing around with it, or trying to import javax.mail.Session directly or anything.
Can anyone think of anything obvious going on? I dont see how email_TransitTime could even work on our portal. I’ve never had any issues using classes I’ve seen used in other config sources or datasources, and I’ve even never hit a problem using imports and code examples I see for java generically. I’ve found super simple examples of code online people are doing that basically are doing something just as minimal, and that line “def smtpSession = Session.getInstance(smtpProps, null);” works for them …. at least for those that could get the javax.mail.Session imported or available to them.
I’m stumped. Help? :)
Thanks!
LM User
·3 years agoI’ve flagged this one for the moderator. We can continue the conversation in your other post.
LM User
·3 years agoYou can technically control what libraries are available for import by putting the files in a specific place in the collector filesystem. However, the real question is whether or not LM ships it with the collector. If they do and you’re missing it, that’s a support issue. If they don’t ship it with the collector, it’s likely you’ll be on your own.
I think the path is /usr/local/logicmonitor/agent/lib on linux. In that directory, I have the following files on a vanilla collector v33.400:
It doesn’t look like javax is in there. However, there may be another path where these things live.