Several times we will see the need of invoking custom Java programs from ODI. Uli has written an excellent article on this.
This is a good solution for the development environment.
However, the limitation of this approach lies in the fact that mandates the need to copy the Jar file to the drivers directory of ODI.
This also needs the agent to be bounced each time a new jar is added.
Think of a scenario where Java agnostic developers wish to use ODI. This is a maintenance overhead for an ODI administrator and also will clutter up the ODI drivers directory. In my opinion, the ODI drivers directory should be used only for Database drivers or application adaptors.
Any custom java code should be used in the following way:
import os
import sys
jars = [
"/home/users/ankit/java/MyFileWrite.jar"
]
for jar in jars:
sys.path.append(jar)
from com.mycompany.MyFileWrite import *
fw=MyFileWrite()
fw.writeFile()
This is a good solution for the development environment.
However, the limitation of this approach lies in the fact that mandates the need to copy the Jar file to the drivers directory of ODI.
This also needs the agent to be bounced each time a new jar is added.
Think of a scenario where Java agnostic developers wish to use ODI. This is a maintenance overhead for an ODI administrator and also will clutter up the ODI drivers directory. In my opinion, the ODI drivers directory should be used only for Database drivers or application adaptors.
Any custom java code should be used in the following way:
import os
import sys
jars = [
"/home/users/ankit/java/MyFileWrite.jar"
]
for jar in jars:
sys.path.append(jar)
from com.mycompany.MyFileWrite import *
fw=MyFileWrite()
fw.writeFile()
7 comments:
hi
what is the actual path of '/home/users/ankit/java/MyFileWrite.jar'. I am getting this error: 'ImportError: no module named FileWrite
'
This is the absolute path of the jar file that contains your methods that you want to use.
If you are using an agent to execute the procedure, then this path should be visible to the agent.
hi Ankit
My jar is at "C:\Oracle\Middleware\Oracle_ODI1\oracledi\agent\drivers" this location...
and i made a java file FileWrite.java which is inside jdk1.6.0_16\bin>
compiled it ,so class file is also dere.
i have written this in my pocedure.......
import os
import sys
jars = [
"C:\Oracle\Middleware\Oracle_ODI1\oracledi\agent\drivers/FileWrite.jar"
]
for jar in jars:
sys.path.append(jar)
from com.mycompany.FileWrite import *
fw=FileWrite()
fw.writeFile()
but got error "No module mycompany found",......so i removed it and wrote only from com.FileWrite import *.....
still error
then wrote only
from FileWrite import *
again this error
org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "", line 11, in ?
ImportError: no module named FileWrite
Please guide wats d problem this time? where i m going wrong?...Waiting for ur reply Thanks in advance...
one thing more in continuation to previous post....I m using Local(No Agent)..
Please correct me ...where i m doing wrong???
Ritika,
Sorry for the delay in response. Were you able to hash this out ?
This post assumes that you have compiled the FileWrite into a FileWrite.class and then packaged into FileWrite.jar
It would be better if you can send your FileWrite.jar
Hi Ankit
This is my code for jar invocation
import os
import sys
jars = [
" D:\JARS_ODI\ODIInvoker.jar"
]
for jar in jars:
sys.path.append(jar)
import com.sample.odi.SqlInsert
sq = com.sample.odi.SqlInsert()
sq.incrementScript()
I got the following error:
ODI-1232: Procedure INVOKE_JAR execution fails.
Caused By: org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "", line 11, in ?
ImportError: No module named sample
What might be the mistake?
Hello,
I am new to ODI, I also get same error
Caused By: org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File "", line 9, in
ImportError: No module named SplitFile
I did not get com.mycompany.MyFileWrite
is this package name or else....
MyFileWrite is jar name or class name....
pls help me solve this exception..
Post a Comment