Re: [Javaserver-perl] Problem at the end of my perl script
Brought to you by:
zzo
|
From: <ma...@zz...> - 2004-03-01 20:14:52
|
Try this:
@@ -57,8 +62,125 @@ sub buildClassesArrayList($$) {
for my $package (keys %{$hashRef}) {
for my $class (keys %{$hashRef->{$package}}) {
my $fullyQualifiedClassName = $package.".".$class;
- my $object = $java->create_object($fullyQualifiedClassName);
- $targetArrayList->add($object->getClass());
+ $targetArrayList->add($java->create_object($fullyQualifiedClassName);
}
}
}
Basically get rid of that 'my $object' & just do the create straight into
the arry list add... maybe that is confusing the destructor...
M
On Mon, Mar 01, 2004 at 02:44:29PM -0500, Don Tam wrote:
> Hi Mark,
>
> Here it is:
>
> #!/usr/local/bin/perl -w
>
> use strict;
> use Java;
>
> sub buildClassesArrayList($$);
>
> my $java = new Java(host=>'deathstar.consumercontact.com');
>
> my %classes = (
> 'com.cc.tss' => {
> 'TaskType' => 1,
> 'Task' => 1,
> 'PayRate' => 1,
> 'Province' => 1,
> 'PaySection' => 1,
> 'PayType' => 1,
> 'Location' => 1,
> 'Department' => 1,
> 'Title' => 1,
> 'Employee' => 1
> },
> 'com.cc.tss.approver' => {
> 'Role' => 1,
> 'ApproverType' => 1,
> 'ApproverLevel' => 1,
> 'Approver' => 1
> }
> );
>
> my $session;
>
>
> eval {
> $session = $java->static_call("com.cc.HibernateApplicationUtil",
> "getSession");
> };
>
> if ($@) {
> $@ =~ s/^ERROR: //;
> $@ =~ s/at $0.*$//;
>
> if ($@ =~ /NullPointerException/) {
> my $arrayList = $java->create_object("java.util.ArrayList");
> buildClassesArrayList(\%classes, $arrayList);
> my $path = `pwd`;
> chomp ($path);
> my $propertiesFileName = $path."/hibernate.properties";
> $java->static_call("com.cc.HibernateApplicationUtil",
> "initConfiguration", $arrayList, $propertiesFileName);
> }
> }
>
> sub buildClassesArrayList($$) {
> my $hashRef = shift;
> my $targetArrayList = shift;
>
> for my $package (keys %{$hashRef}) {
> for my $class (keys %{$hashRef->{$package}}) {
> my $fullyQualifiedClassName = $package.".".$class;
> my $object = $java->create_object($fullyQualifiedClassName);
> $targetArrayList->add($object->getClass());
> }
> }
> }
>
> I will continue to look at it as well.
>
> Thanks,
> Don.
>
> ma...@zz... wrote:
>
> >Seems the object is somehow already getting cleaned up before the
> >global DESTROY gets called.
> >If you know what object is causing the problem you can undef it.
> >I will add a check to Java.pm for future releases too so this doesn't
> >happen.
> >If your script isn't too long I'll take a look at it - otherwise there
> >seems to be a mis-matched between creating and destroying of your
> >perl-created java objects.
> > Mark
> >
> >
> >On Mon, Mar 01, 2004 at 02:26:55PM -0500, Don Tam wrote:
> >
> >
> >>Hi,
> >>
> >>Thanks for the reply. I am running the latest Java.pm.. I just
> >>downloaded the 4.7 package on thursday (revision 1.3, it looks like).
> >>
> >>How would I avoid this?
> >>
> >>thanks,
> >>Don.
> >>
> >>ma...@zz... wrote:
> >>
> >>
> >>
> >>>Maybe a java object has already been destroy'ed before it went out
> >>>of scope/the program ended.
> >>>Java.pm tries to be smart & delete objects on the server-side when they
> >>>go out of scope on the perl side. It's prolly not being smart enough.
> >>>What version of Java.pm are you running?
> >>> Mark
> >>>
> >>>On Mon, Mar 01, 2004 at 01:30:52PM -0500, Don Tam wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Hi,
> >>>>
> >>>>I keep getting this error, but the script seems to run fine:
> >>>>
> >>>>Use of uninitialized value in concatenation (.) or string at
> >>>>/usr/lib/perl5/site
> >>>>_perl/5.8.0/Java.pm line 640 during global destruction.
> >>>> (in cleanup) Can't call method "send_command_and_get_response"
> >>>>on an und
> >>>>efined value at /usr/lib/perl5/site_perl/5.8.0/Java.pm line 640 during
> >>>>global de
> >>>>struction.
> >>>>
> >>>>Anyone know what's going on?
> >>>>
> >>>>Thanks,
> >>>>
> >>>>--
> >>>>Don Tam
> >>>>Software Developer
> >>>>(416)493-6111x177
> >>>>dt...@co...
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>-------------------------------------------------------
> >>>>SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> >>>>Build and deploy apps & Web services for Linux with
> >>>>a free DVD software kit from IBM. Click Now!
> >>>>http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> >>>>_______________________________________________
> >>>>Javaserver-perl mailing list
> >>>>Jav...@li...
> >>>>https://lists.sourceforge.net/lists/listinfo/javaserver-perl
> >>>>
> >>>>
> >>>>
> >>>>
> >>--
> >>Don Tam
> >>Software Developer
> >>(416)493-6111x177
> >>dt...@co...
> >>
> >>
> >>
> >>
> >>
>
> --
> Don Tam
> Software Developer
> (416)493-6111x177
> dt...@co...
>
>
>
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Javaserver-perl mailing list
> Jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javaserver-perl
|