Problem encountered when trying to pass objects using JPL
[email protected] ("Stephen Burns") Thu, 10 Jun 2004 13:54:51 +0100
| Newsgroups | perl.jpl |
|---|---|
| Message-ID | <[email protected]> |
------_=_NextPart_001_01C44EEA.1EBA3DF9
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Firstly I would like to apologise for the length of this posting but if =
you can help please read on...
I am attempting to build a Java wrapper to an existing Perl API. The =
API performs updates over a network connection to a second server, which =
therefore requires a connection to be established, utilised and finally =
torn down (in a similar fashion to a database connection).
To avoid the overhead of creating and destroying the connection for each =
update, I am attempting to create the Perl object, pass this back into =
the Java which in turn pass the object to various other Perl procedures =
to perform the updates and finally tear down the connection.
I attempt the following using JPL:
class JPLSXIExample
{
perl void deleteSXIConnection (Object obj1) {{
use SXI;
my $SXIConn =3D $obj1;
print "deleteSXIConnection: SXIConn: $SXIConn\n";
bless $SXIConn, SXI;
print "deleteSXIConnection: SXIConnAfterBless: $SXIConn\n";
$SXIConn->delete();
}}
perl Object getSXIConnection () {{
use SXI;
my $SXIConn;
$SXIConn =3D new SXI{<<parameters>>} if !defined($SXIConn);
print "getSXIConnection: SXIConn: $SXIConn\n";
return bless $SXIConn, SXI;
}}
void test()=20
{
/* Get a connection */
System.out.println("Attempting to get an object of type SXI");
Object mySXI =3D getSXIConnection();
System.out.println("Successfully retrieved Object");
/* delete the connection */
System.out.println("Attempting Delete the conncetion to the SXI =
Server");
deleteSXIConnection(mySXI);
System.out.println("Successfully passed the object and used it");
}
=20
public static void main(String[] argv) {
JPLSXIExample demo =3D new JPLSXIExample();
demo.test();
}
}
The output from running the above is shown below.
java JPLSXIExample
Attempting to get an object of type SXI
getSXIConnection: SXIConn: SXI=3DHASH(0xf3e60)
Successfully retrieved Object
Attempting Delete the conncetion to the SXI Server
deleteSXIConnection: SXIConn1: java::lang::Object=3DSCALAR(0xf3e60)
deleteSXIConnection: SXIConnAfterBless: SXI=3DSCALAR(0xf3e60)
Exception in thread "main" java.lang.RuntimeException: (in cleanup) Not =
a HASH reference at /usr/local/lib/perl5/site_perl/5.8.4/SXI.pm line =
2936.
at JPLSXIExample.deleteSXIConnection(Native Method)
at JPLSXIExample.test(JPLSXIExample.java:57)
at JPLSXIExample.main(JPLSXIExample.java:63)
make: *** [test] Error 1
As can be seen the act of passing the object from one Perl procedure to =
another via Java seems to cause the object to be forced to a SCALER as =
opposed to a HASH!!
I would appreciate if anyone can shed any light on this, even to =
discredit it.
Many thanks in advance.
Stephen Burns
Stephen Burns
Senior Systems Designer
Real Time Engineering Ltd.
The information contained in this e-mail may contain confidential or =
privileged material and is intended only for the person or entity to =
which it is addressed. If you are not the intended recipient, the use, =
disclosure, copying or distribution of this information is prohibited =
and may be unlawful. If you have received it in error, please notify us =
immediately by telephone (+44 (0)141 427 4142). Please also destroy and =
delete the message from your computer. The opinions contained within =
this e-mail are not necessarily the opinions of Real Time Engineering =
Limited.
------_=_NextPart_001_01C44EEA.1EBA3DF9
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.0.6249.1">
<TITLE>Problem encountered when trying to pass objects using JPL</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=3D2 FACE=3D"Arial">Firstly I would like to apologise for =
the length of this posting but if you can help please read on...</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">I am attempting to build a Java wrapper =
to an existing Perl API. The API performs updates over a network =
connection to a second server, which therefore requires a connection to =
be established, utilised and finally torn down (in a similar fashion to =
a database connection).</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">To avoid the overhead of creating and =
destroying the connection for each update, I am attempting to create the =
Perl object, pass this back into the Java which in turn pass the object =
to various other Perl procedures to perform the updates and finally tear =
down the connection.</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">I attempt the following using =
JPL:</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">class JPLSXIExample</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> perl void deleteSXIConnection =
(Object obj1) {{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> use SXI;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> my $SXIConn =3D =
$obj1;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> print =
"deleteSXIConnection: SXIConn: $SXIConn\n";</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> bless $SXIConn, =
SXI;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> print =
"deleteSXIConnection: SXIConnAfterBless: $SXIConn\n";</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
$SXIConn->delete();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> }}</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> perl Object getSXIConnection () =
{{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> use SXI;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> my $SXIConn;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> $SXIConn =3D new =
SXI{<<parameters>>} if !defined($SXIConn);</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> print =
"getSXIConnection: SXIConn: $SXIConn\n";</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> return bless =
$SXIConn, SXI;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> }}</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial"> void test() </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> {</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> /* Get a connection =
*/</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
System.out.println("Attempting to get an object of type =
SXI");</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> Object mySXI =3D =
getSXIConnection();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
System.out.println("Successfully retrieved Object");</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> /* delete the =
connection */</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
System.out.println("Attempting Delete the conncetion to the SXI =
Server");</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
deleteSXIConnection(mySXI);</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
System.out.println("Successfully passed the object and used =
it");</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> }</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> public static void =
main(String[] argv) {</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> JPLSXIExample demo =
=3D new JPLSXIExample();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> demo.test();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> }</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">The output from running the above is =
shown below.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">java JPLSXIExample</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Attempting to get an object of type =
SXI</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">getSXIConnection: SXIConn: =
SXI=3DHASH(0xf3e60)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Successfully retrieved Object</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Attempting Delete the conncetion to =
the SXI Server</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">deleteSXIConnection: SXIConn1: =
java::lang::Object=3DSCALAR(0xf3e60)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">deleteSXIConnection: =
SXIConnAfterBless: SXI=3DSCALAR(0xf3e60)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Exception in thread "main" =
java.lang.RuntimeException: (in cleanup) Not a HASH reference at =
/usr/local/lib/perl5/site_perl/5.8.4/SXI.pm line 2936.</FONT></P>
<P><FONT SIZE=3D2 =
FACE=3D"Arial"> at =
JPLSXIExample.deleteSXIConnection(Native Method)</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> at =
JPLSXIExample.test(JPLSXIExample.java:57)</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> at =
JPLSXIExample.main(JPLSXIExample.java:63)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">make: *** [test] Error 1</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">As can be seen the act of passing the =
object from one Perl procedure to another via Java seems to cause the =
object to be forced to a SCALER as opposed to a HASH!!</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">I would appreciate if anyone can shed =
any light on this, even to discredit it.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Many thanks in advance.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Stephen Burns</FONT>
</P>
<P><SPAN LANG=3D"en-gb"><B><FONT SIZE=3D1 FACE=3D"Verdana">Stephen =
Burns</FONT></B><BR>
<FONT SIZE=3D1 FACE=3D"Verdana">Senior Systems Designer<BR>
Real Time Engineering Ltd.</FONT></SPAN>
</P>
<BR>
<P><SPAN LANG=3D"en-gb"><FONT COLOR=3D"#808080" SIZE=3D1 =
FACE=3D"Arial">The information contained in this e-mail may contain =
confidential or privileged material and is intended only for the person =
or entity to which it is addressed. If you are not the intended =
recipient, the use, disclosure, copying or distribution of this =
information is prohibited and may be unlawful. If you have =
received it in error, please notify us immediately by telephone (+44 =
(0)141 427 4142). Please also destroy and delete the message from =
your computer. The opinions contained within this e-mail are not =
necessarily the opinions of Real Time Engineering =
Limited.</FONT></SPAN></P>
</BODY>
</HTML>
------_=_NextPart_001_01C44EEA.1EBA3DF9--