Getting the Java UDR examples to work on IIF9.21.UC4 (Linux) 
Author Message
 Getting the Java UDR examples to work on IIF9.21.UC4 (Linux)

IIF comes with all these fancy ORDBMS features, like being able to
create User Defined Routines (UDRs) and User Defined Types (UDTs) using
C or Java. Getting them to work (even with the installed examples), can
be a challenge, though. The examples are supposed to compile and run
using a Makefile and run.sh in the $INFORMIXDIR/extend/krakatoa/examples
directory. It's not quite that easy, though.

Here are some gotchas that I found in trying to get the example programs
to run on Red Hat Linux 7.1. I hope these tips can save someone some of
the frustration I endured. Except as noted, I did everything with the
informix user id (proper permissions are already set on the example files).

#1 - Check and recheck the configuration parameters in onconfig. Since
you have to bounce the server for them to take effect, you don't want to
be messing with them. The documentation on these is pretty good. I'll
comment just on a few of them.
VPCLASS    jvp,num=1
You must have this line (it is usually commented out). This counts as a
CPU VP, sort of. On a single CPU machine, you will need NUMCPUVPS set to
1, but SINGLE_CPU_VP set to 0.
JVP* - these five parameters require you to type in the value of
$INFORMIXDIR before /extend ... They default to /usr/informix.
JVPJAVALIB - should be /lib/i386 (NOTE: no ending slash). For some
strange reason this defaults to /lib/sparc/ (this sparc error pops up again)
JVPCLASSPATH - make sure you change all the directories in the list to
the proper $INFORMIXDIR. I tripped on this twice.

# 2 - Add lines to the /etc/ld.so.conf. This too is documented. As root,
add the following lines, substituting the actual value of $INFORMIXDIR:
$INFORMIXDIR/extend/krakatoa/jre/lib/i386
$INFORMIXDIR/extend/krakatoa/jre/lib/i386/native_threads
$INFORMIXDIR/extend/krakatoa/jre/lib/i386/classic
Then run ldconfig

# 3 - Make sure $INFORMIXDIR/extend/krakatoa/.jvpprops exists in the
directory you specified in ONCONFIG (usually
$INFORMIXDIR/extend/krakatoa). There is a .jvpprops.template that you
can copy. These configuration parameters are documented.

# 4 - Java compiler. Make sure to use 1.2.2 compiler from Blackdown. I
have heard that you can compile with a 1.3 JDK, but when I tried I
either crashed the server or caused an assertion failure (upon running
the examples, not compiling). If you have multiple JDKs on your server,
edit the Makefile to point to the correct 1.2.2 javac and jar
executables. I added a JDK = /path/to/javac and JAR = /path/to/jar
variable at the top and then edited the .java.class: to be $(JDK) $<
and .class.jar: to be $(JAR) ... (the rest of the line)
There will be a few more changes to the Makefile later on.

# 5 - Setjdk. I stumbled across this and have never seen any
documentation for it. setjdk is a linking script in
$INFORMIXDIR/extend/krakatoa. It removes and creates some necessary
links for the Java UDRs to work. It may get run during installation, but
it is wrong anyway. You must edit the file and re-run it or you will get
messages from the examples like "cannot find
$INFORMIXDIR/extend/krakatoa/jre/lib/i386/libnet.so" even though the
files are there. The problem is that the path in the setjdk script uses
/lib/sparc (?!?) instead of /lib/i386. Fix all these (in vi :1,$
s/sparc/i386/g) and then execute it with the proper parameters:
./setjdk jdk12 $INFORMIXDIR
(use the actual value of $INFORMIXDIR)

# 6 - Fix the .sql files. Again, this is somewhere in the documentation.
Update all the pathnames with the value of $INFORMIXDIR.

# 7 - C compiling/linking problems. First check that the CC variable in
the Makefile is the name of your compiler. The default is egcs (I
think). I changed mine to gcc (probably pretty common). There is a
second, obscure problem that an Grant Flander, an IBM/Informix tech,
happened upon. I don't pretend to understand it, but it does get the C
types and UDRs to work. Java is our main concern, so I haven't fully
investigated this or figured out the best way to solve it for real
projects. In the Makefile, add -shared -u _etext to the SOFLAGS
variable. NOTE: if you have already executed run.sh (or make), you will
need to remove circle.o and circle.so (the C UDRs) manually (so they get
recompiled).

You should now be able to execute run.sh and watch the examples fly by.
(You can do ./run.sh > out 2>&1 and then just view the file for
results.) The examples create a mydb database with the UDRs, UDTs, and a
bit of sample data. They execute the UDRs so you can see if they
actually work. You can essentially test the same thing by going into
dbaccess and doing:
select c, area(c) from mytable;
It should return 3 rows with x, y, radius, and a computed area.

# 8 - Java UDR permissions (thanks to Allen at Ned Davis Researchfor
figuring this one out). If you try that same select as a different user
(once you've granted connect privileges), you wil see that you don't
have permission to execute it, no matter how you grant it. This is a
documented bug:

http://www.***.com/ %2Fbug_deets.html&buglist=132678

The workaround (for the examples) is to specify the owner's name during
the creation of the objects. Edit the .sql files where they do create
function and add informix. to the external name, e.g., external name
'informix.circle_jar:Circle.area(Circle)' A second work around (for use
in your own projects) is to use deployment descriptors and manifests in
creating the jar. Further explanation of that is left to the Java gurus.

Please send comments/corrections/donations :) to:



Sat, 12 Jun 2004 01:24:59 GMT
 
 [ 1 post ] 

 Relevant Pages 

1. ASSERT FAIL IDS9.21.UC4 on Linux

2. process hung on Dynamic Server 2000 Version 9.21.UC4

3. IDS 9.21.UC4 on Solaris

4. Mutex Lock for Informix 9.21.UC4

5. Informix IDS-9.21-UC4-1 and UnixWare 7.1.1

6. buildsmi V7.30.UC8 ->9.21.UC4

7. mysql 3.21.29a win32 -- tables getting corrupted

8. ANN: jdance.com Dec 21 Java News

9. Diff between 9.21.UC3-1 and 9.21.HC3-1

10. FW: Diff between 9.21.UC3-1 and 9.21.HC3-1

11. upgrading IIF-9.21-UC2 to IIF-9.21-UC3 and select became

12. IIF.20009.21 on Linux and shadow password/PAM


 
Powered by phpBB® Forum Software