OpenNMS Scriptd configuration not working

Problem:
[We are facing multiple Errros when trying to forward traps using scriptd to another Server that will release SMS on the traps received]

Expected outcome:
[Traps should be sent successfully]

OpenNMS version:

Other relevant data:
[e.g. logs from OpenNMS, error messages etc]

2021-04-08 10:51:05,679 ERROR [Scriptd-Executor-Thread] o.o.n.s.Executor: Non-UEI-specific event handler script execution failed : org.opennms.netmgt.config.scriptd.EventScript@48659ab2
org.apache.bsf.BSFException: BeanShell script error: Sourced file: inline evaluation of: ``             event = bsf.lookupBean("event");                if (event.snmp != null) {                       log.debug("F . . . '' : Error in method invocation: Method forwardTrap( org.opennms.netmgt.events.api.model.ImmutableEvent, java.lang.String, int ) not found in class'org.opennms.netmgt.scriptd.helper.SnmpTrapHelper' : at Line: 6 : in file: inline evaluation of: ``               event = bsf.lookupBean("event");                if (event.snmp != null) {                       log.debug("F . . . '' : snmpTrapHelper .forwardTrap ( event , "10.202.0.7" , 162 )
 BSF info:  at line: 0 column: columnNo
        at bsh.util.BeanShellBSFEngine.eval(Unknown Source) ~[bsh-1.3.0.jar:?]
        at bsh.util.BeanShellBSFEngine.exec(Unknown Source) ~[bsh-1.3.0.jar:?]
        at org.apache.bsf.BSFManager$6.run(BSFManager.java:493) ~[bsf-2.4.0.jar:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at org.apache.bsf.BSFManager.exec(BSFManager.java:491) ~[bsf-2.4.0.jar:?]
        at org.opennms.netmgt.scriptd.Executor.executeEventScripts(Executor.java:287) ~[opennms-services-26.1.1.jar:?]
        at org.opennms.netmgt.scriptd.Executor.access$600(Executor.java:68) ~[opennms-services-26.1.1.jar:?]
        at org.opennms.netmgt.scriptd.Executor$ScriptdRunnable.lambda$run$0(Executor.java:214) ~[opennms-services-26.1.1.jar:?]
        at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.withManualFlush(DefaultSessionUtils.java:81) ~[opennms-dao-26.1.1.jar:?]
        at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.lambda$withReadOnlyTransaction$1(DefaultSessionUtils.java:73) ~[opennms-dao-26.1.1.jar:?]
        at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.executeWithTransactionDefinition(DefaultSessionUtils.java:95) [opennms-dao-26.1.1.jar:?]
        at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.withReadOnlyTransaction(DefaultSessionUtils.java:73) [opennms-dao-26.1.1.jar:?]
        at org.opennms.netmgt.scriptd.Executor$ScriptdRunnable.run(Executor.java:213) [opennms-services-26.1.1.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at org.opennms.core.concurrent.LogPreservingThreadFactory$2.run(LogPreservingThreadFactory.java:106) [opennms-util-26.1.1.jar:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]

Script

<?xml version="1.0"?>
<scriptd-configuration>
        <engine language="beanshell" className="bsh.util.BeanShellBSFEngine" extensions="bsh"/>

        <start-script language="beanshell">

                import org.opennms.core.utils.InetAddressUtils;
                import org.opennms.netmgt.snmp.SnmpTrapBuilder;
                import org.opennms.core.db.DataSourceFactory;
                import org.opennms.core.utils.SingleResultQuerier;
                import org.opennms.netmgt.xml.event.Event;
                import org.opennms.netmgt.scriptd.helper;

                log = bsf.lookupBean("log");
                snmpTrapHelper = new org.opennms.netmgt.scriptd.helper.SnmpTrapHelper();

                server(12345);
                source("/opt/opennms/etc/scriptd-event-forwarder.bsh");

        </start-script>

        <stop-script language="beanshell">

                snmpTrapHelper.stop();
                log.debug("executing a stop script");

        </stop-script>

        <event-script language="beanshell">

                event = bsf.lookupBean("event");
                forwardEvent(event);

        </event-script>

        <event-script language="beanshell">

                event = bsf.lookupBean("event");
                if (event.snmp != null) {
                        log.debug("Forwarding a trap");
                        snmpTrapHelper.forwardTrap(event, "abcip", 162);
                }

        </event-script>

</scriptd-configuration>

This needs to be ImmutableEvent.

import org.opennms.netmgt.events.api.model.IEvent;

I have changed this in the script aswell.
Still facing the same error.

2021-04-09 11:21:25,647 ERROR [Scriptd-Executor-Thread] o.o.n.s.Executor: Non-UEI-specific event handler script execution failed : org.opennms.netmgt.config.scriptd.EventScript@48659ab2

org.apache.bsf.BSFException: BeanShell script error: Sourced file: inline evaluation of: event = bsf.lookupBean("event"); if (event.snmp != null) { log.debug("F . . . '' : Error in method invocation: Method forwardTrap( org.opennms.netmgt.events.api.model.ImmutableEvent, java.lang.String, int ) not found in class'org.opennms.netmgt.scriptd.helper.SnmpTrapHelper' : at Line: 6 : in file: inline evaluation of: event = bsf.lookupBean(β€œevent”); if (event.snmp != null) {
log.debug("F . . . β€˜β€™ : snmpTrapHelper .forwardTrap ( event , β€œ10.202.0.7” , 162 )
BSF info: at line: 0 column: columnNo
at bsh.util.BeanShellBSFEngine.eval(Unknown Source) ~[bsh-1.3.0.jar:?]
at bsh.util.BeanShellBSFEngine.exec(Unknown Source) ~[bsh-1.3.0.jar:?]
at org.apache.bsf.BSFManager$6.run(BSFManager.java:493) ~[bsf-2.4.0.jar:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
at org.apache.bsf.BSFManager.exec(BSFManager.java:491) ~[bsf-2.4.0.jar:?]
at org.opennms.netmgt.scriptd.Executor.executeEventScripts(Executor.java:287) ~[opennms-services-26.1.1.jar:?]
at org.opennms.netmgt.scriptd.Executor.access$600(Executor.java:68) ~[opennms-services-26.1.1.jar:?]
at org.opennms.netmgt.scriptd.Executor$ScriptdRunnable.lambda$run$0(Executor.java:214) ~[opennms-services-26.1.1.jar:?]
at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.withManualFlush(DefaultSessionUtils.java:81) ~[opennms-dao-26.1.1.jar:?]
at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.lambda$withReadOnlyTransaction$1(DefaultSessionUtils.java:73) ~[opennms-dao-26.1.1.jar:?]
at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.executeWithTransactionDefinition(DefaultSessionUtils.java:95) [opennms-dao-26.1.1.jar:?]
at org.opennms.netmgt.dao.hibernate.DefaultSessionUtils.withReadOnlyTransaction(DefaultSessionUtils.java:73) [opennms-dao-26.1.1.jar:?]
at org.opennms.netmgt.scriptd.Executor$ScriptdRunnable.run(Executor.java:213) [opennms-services-26.1.1.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at org.opennms.core.concurrent.LogPreservingThreadFactory$2.run(LogPreservingThreadFactory.java:106) [opennms-util-26.1.1.jar:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
2021-04-09 11:21:25,647 DEBUG [Scriptd-Executor-Thread] o.o.n.s.Executor: Finished executing scripts for: uei.opennms.org/traps/HH3C-TRAP-MIB/hh3cPeriodicalTrap

You don’t appear to have forwardTrap(...) defined anywhere?

As per our understanding forward trap is part of the in built library that are being imported.

We are still stuck. Any more ideas on how to resolve this issue.