ODI Groovy Script Executes With Success In ODI Groovy Console, But The Same Code Fails When Executed In An ODI Procedure With Error "org.apache.bsf.BSFException: exception from Groovy: groovy.lang.MissingPropertyException: No such property: odiInstance" (Doc ID 1605709.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Data Integrator - Version 11.1.1.3.0 and later
Information in this document applies to any platform.

Symptoms

A Groovy script is created similar to that provided in link https://blogs.oracle.com/warehousebuilder/entry/odi_11g_scripting_the_model

The following script is executed with success in the ODI Groovy Console:

import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition;
import oracle.odi.domain.util.ObfuscatedString;
import oracle.odi.domain.model.OdiModel;
import oracle.odi.domain.topology.OdiLogicalSchema;
import oracle.odi.domain.topology.OdiPhysicalSchema;
import oracle.odi.domain.topology.OdiDataServer;
import oracle.odi.domain.topology.OdiContext;
import oracle.odi.domain.topology.OdiTechnology;
import oracle.odi.domain.topology.OdiContextualSchemaMapping;
import oracle.odi.domain.topology.AbstractOdiDataServer;
import oracle.odi.domain.topology.finder.IOdiContextFinder;
import oracle.odi.domain.topology.finder.IOdiTechnologyFinder;
def createLogicalSchema(contextCode, techCode, schName, dataserverName, userName, password, url, driver, schema) {
 txnDef = new DefaultTransactionDefinition();
 tm = odiInstance.getTransactionManager()
 txnStatus = tm.getTransaction(txnDef)
 contextFinder = (IOdiContextFinder) odiInstance.getTransactionalEntityManager().getFinder(OdiContext.class);
 context = contextFinder.findByCode(contextCode);
 techFinder = (IOdiTechnologyFinder) odiInstance.getTransactionalEntityManager().getFinder(OdiTechnology.class);
 tech = techFinder.findByCode(techCode);
 lschema = new OdiLogicalSchema(tech, schName)
 dserver = new OdiDataServer(tech, dataserverName)
 con = new AbstractOdiDataServer.JdbcSettings(url, driver)
 dserver.setConnectionSettings(con)
 dserver.setUsername(userName)
 dserver.setPassword(password)
 pschema = new OdiPhysicalSchema(dserver)
 pschema.setSchemaName(schema)
 pschema.setWorkSchemaName(schema)
 cschema = new OdiContextualSchemaMapping(context, lschema, pschema)
 odiInstance.getTransactionalEntityManager().persist(lschema)
 odiInstance.getTransactionalEntityManager().persist(dserver)
 tm.commit(txnStatus)
 return lschema
}

lschema = createLogicalSchema("DEV", "ORACLE", "LS_TEST", "DS_TEST", "ODI_TEST", ObfuscatedString.obfuscate("odi_test"),
"jdbc:oracle:thin:@testserver:1521:DB", "oracle.jdbc.OracleDriver", "ODI_TEST")

When the same script is added to an ODI procedure | Command on Target | Technology Groovy, an error occurs preventing the script from executing with success.

Error captured:

org.apache.bsf.BSFException: exception from Groovy: groovy.lang.MissingPropertyException: No such property: odiInstance for class: groovy
    at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:110)
    at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.execInBSFEngine(SnpScriptingInterpretor.java:322)
    at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.exec(SnpScriptingInterpretor.java:170)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java:2472)
    at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:47)
    at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:1)
    at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
    at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:662)
Caused by: groovy.lang.MissingPropertyException: No such property: odiInstance for class: groovy
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:241)
    at groovy.createLogicalSchema(groovy:15)
    at groovy$createLogicalSchema.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
    at groovy.run(groovy:37)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:576)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:614)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:595)
    at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:108)
    ... 19 more

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms