Forum Discussion

Lewis_Beard's avatar
2 years ago

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:

“No such property: Session for class”As it happens on our portal, nobody is even using email_TransitTime, so I cant really be sure, but it seems like something may be wrong on the portal.

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!

  • Anonymous's avatar
    Anonymous

    I’ve flagged this one for the moderator. We can continue the conversation in your other post.

  • Anonymous's avatar
    Anonymous

    You 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:

    MOD-1.5.3.jar
    TACACS-1.0.0.jar
    accessors-smart-2.4.7.jar
    activation-1.1.1.jar
    agent.jar
    amazonlibs
    apache-mime4j-0.6.jar
    asm-9.1.jar
    asm-commons.jar
    asm.jar
    asn-one-0.6.0.jar
    bcpkix-jdk15on-1.69.jar
    bcprov-jdk15on-1.69.jar
    bcutil-jdk15on-1.69.jar
    bigqueue-0.7.11.jar
    bson-4.1.2.jar
    certexpire.jar
    checker-qual-3.5.0.jar
    chronicle-algorithms-2.20.80.jar
    chronicle-bytes-2.20.101.jar
    chronicle-core-2.20.104.jar
    chronicle-map-3.20.83.jar
    chronicle-threads-2.20.100.jar
    chronicle-values-2.20.80.jar
    chronicle-wire-2.20.101.jar
    client-java-14.0.0.jar
    client-java-api-14.0.0.jar
    collectorInfo.txt
    commons-beanutils-1.9.4.jar
    commons-cli-1.2.jar
    commons-codec-1.15.jar
    commons-collections-3.2.2.jar
    commons-collections4-4.1.jar
    commons-compress-1.21.jar
    commons-configuration-1.8.jar
    commons-digester-1.8.1.jar
    commons-io-2.8.0.jar
    commons-lang-2.6.jar
    commons-lang3-3.7.jar
    commons-logging-1.2.jar
    commons-logging-api-1.0.4.jar
    commons-modeler-2.0.1.jar
    commons-net-3.9.0.jar
    commons-pool2-2.6.0.jar
    commons-validator-1.6.jar
    core
    db2jcc4-1.0.jar
    disruptor-3.3.0.jar
    dnsjava-2.1.3.jar
    eddsa-0.3.0.jar
    error_prone_annotations-2.3.4.jar
    extended
    failureaccess-1.0.1.jar
    fastjson-1.2.83.jar
    forms_rt.jar
    gmbal-api-only-4.0.3.jar
    grapeConfig.xml
    groovy
    groovy-all-2.4.15.jar
    gson-2.8.9.jar
    gson-fire-1.8.5.jar
    guava-30.1-jre.jar
    hsqldb-2.7.1.jar
    httpasyncclient-4.1.4.5.jar
    httpclient-4.5.13.jar
    httpcore-4.4.13.jar
    httpcore-nio-4.4.10.3.jar
    httpmime-4.5.2.jar
    icu4j-60.2.jar
    install
    ipaddress-5.2.1.jar
    istack-commons-runtime-4.0.1.jar
    ivy-2.5.1.jar
    j2objc-annotations-1.3.jar
    jackson-annotations-2.13.4.jar
    jackson-core-2.13.4.jar
    jackson-databind-2.13.4.2.jar
    jackson-dataformat-cbor-2.11.4.jar
    jakarta.activation-2.0.1.jar
    jakarta.mail-2.0.1.jar
    java-allocation-instrumenter-3.0.jar
    javac2.jar
    javacsv-2.0.jar
    javapoet-1.12.1.jar
    javax.activation-api-1.2.0.jar
    javax.jws-api-1.1.jar
    javax.xml.soap-api-1.4.0.jar
    jaxb-api-2.4.0-b180830.0359.jar
    jaxb-runtime-2.3.2.jar
    jaxws-api-2.3.1.jar
    jaxws-rt-2.3.1.jar
    jboss-logging-3.4.1.Final.jar
    jboss-marshalling-2.0.10.Final.jar
    jboss-marshalling-river-2.0.10.Final.jar
    jboss-remoting-5.0.17.Final.jar
    jcifs-1.3.15.jar
    jconn4-1.0.jar
    jdom.jar
    jedis-2.9.0.jar
    jetty-continuation-8.1.12.v20130726.jar
    jetty-http-11.0.11.jar
    jetty-io-11.0.11.jar
    jetty-jakarta-servlet-api-5.0.2.jar
    jetty-server-11.0.11.jar
    jetty-util-11.0.11.jar
    jmxremote_optional-1.0.jar
    jna-4.5.2.jar
    jna-platform-4.5.2.jar
    joda-time-2.9.1.jar
    jsch-0.1.53.1.jar
    json-20140107.jar
    json-path-2.5.0.jar
    json-smart-2.4.7.jar
    jsoup-1.15.3.jar
    jsr305-3.0.2.jar
    jzlib-1.1.3.jar
    kotlin-stdlib-1.4.10.jar
    libpcap64.so
    librocksaw64.so
    listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
    lm-opentracing-concurrent-0.0.1-2017070501-SNAPSHOT.jar
    lmbatchjobwrapper.sh
    lmlogger.jar
    log4j-1.2-api-2.17.1.jar
    log4j-api-2.17.1.jar
    log4j-core-2.17.1.jar
    log4j2.properties
    logger.properties
    logicmonitor-common.jar
    logicmonitor-util.jar
    logsearch.jar
    lz4-java-1.5.0.jar
    management-api-3.2.3.jar
    manageontap-5.4P1.jar
    mariadb-java-client-2.5.4.jar
    memcached-2.0.1.jar
    metrics-1.0.0.jar
    mongodb-driver-core-4.1.2.jar
    mongodb-driver-sync-4.1.2.jar
    mssql-jdbc-7.4.1.jre11.jar
    netty-all-4.1.86.Final.jar
    netty-buffer-4.1.86.Final.jar
    netty-codec-4.1.86.Final.jar
    netty-codec-dns-4.1.86.Final.jar
    netty-codec-haproxy-4.1.86.Final.jar
    netty-codec-http-4.1.86.Final.jar
    netty-codec-http2-4.1.86.Final.jar
    netty-codec-memcache-4.1.86.Final.jar
    netty-codec-mqtt-4.1.86.Final.jar
    netty-codec-redis-4.1.86.Final.jar
    netty-codec-smtp-4.1.86.Final.jar
    netty-codec-socks-4.1.86.Final.jar
    netty-codec-stomp-4.1.86.Final.jar
    netty-codec-xml-4.1.86.Final.jar
    netty-common-4.1.86.Final.jar
    netty-handler-4.1.86.Final.jar
    netty-handler-proxy-4.1.86.Final.jar
    netty-handler-ssl-ocsp-4.1.86.Final.jar
    netty-resolver-4.1.86.Final.jar
    netty-resolver-dns-4.1.86.Final.jar
    netty-resolver-dns-classes-macos-4.1.86.Final.jar
    netty-resolver-dns-native-macos-4.1.86.Final-osx-aarch_64.jar
    netty-resolver-dns-native-macos-4.1.86.Final-osx-x86_64.jar
    netty-transport-4.1.86.Final.jar
    netty-transport-classes-epoll-4.1.86.Final.jar
    netty-transport-classes-kqueue-4.1.86.Final.jar
    netty-transport-native-epoll-4.1.86.Final-linux-aarch_64.jar
    netty-transport-native-epoll-4.1.86.Final-linux-x86_64.jar
    netty-transport-native-kqueue-4.1.86.Final-osx-aarch_64.jar
    netty-transport-native-kqueue-4.1.86.Final-osx-x86_64.jar
    netty-transport-native-unix-common-4.1.86.Final.jar
    netty-transport-rxtx-4.1.86.Final.jar
    netty-transport-sctp-4.1.86.Final.jar
    netty-transport-udt-4.1.86.Final.jar
    npcapinstaller.jar
    okhttp-4.9.1.jar
    okio-2.8.0.jar
    opentracing-api-0.30.0.jar
    opentracing-noop-0.30.0.jar
    opentracing-util-0.30.0.jar
    oracle_jdbc-1.1.jar
    pcap4j-core-1.7.1.jar
    pcap4j-packetfactory-static-1.7.1.jar
    policy-3.0.1.jar
    postgresql-42.4.1.jar
    quartz-1.6.0.jar
    readme.md
    remoting-jmx-3.0.0.Final.jar
    rocksaw-0.6.2.jar
    saaj-impl-1.5.0.jar
    sblim-cim-client2-2.1.12.jar
    sblinuxproxy
    sblinuxproxy.lock
    sblinuxproxy.pid
    sbproxy.port
    service-detector.jar
    slf4j-api-1.7.30.jar
    slf4j-simple-1.6.0.jar
    snappy-java-1.1.4.jar
    snippets
    snmp4j-2.7.0.jar
    sqljdbc.jar
    sse
    sse.jar
    ssecommon-0.0.1.jar
    sshj-0.32.0.jar
    stax-ex-2.0.1.jar
    streambuffer-2.0.2.jar
    synthetics-monitoring-all-in-one.jar
    syslog4j-0.9.46-bin.jar
    telnet.jar
    templates
    tinyradius-1.1.2.jar
    vijava-2.0.1.jar
    vsan-2.0.1.jar
    vserv-tcpip-0.9.1.jar
    wbem.jar
    wildfly-client-config-1.0.0.Final.jar
    wildfly-common-1.5.4.Final.jar
    wildfly-elytron-2.0.0.Final.jar
    wrapper.jar
    wrapperApp.jar
    ws-commons-util-1.0.2.jar
    xenserver-5.5.0-1.jar
    xml-apis-1.0.b2.jar
    xmlrpc-client-3.1.1.jar
    xmlrpc-common-3.1.0.jar
    xnio-api-3.5.1.Final.jar
    xnio-nio-3.5.1.Final.jar
    xz_compress_algorithm-1.0.jar

    It doesn’t look like javax is in there. However, there may be another path where these things live.