rupesht has asked for the wisdom of the Perl Monks concerning the following question:

We are having libxm2 version 2.6.16-12.9 and perl-5.8.5-57.We are getting following errors intermittently when calling a perl script through a C program.

Can't locate object method "new" via package "XML::LibXML::SAX" at /us +r/lib/perl5/vendor_perl/5.8.5/XML/SAX/ParserFactory.pm line 43. Compilation failed in require at /app/base_lib/mycommon_mod1.pm line 8 +8. BEGIN failed--compilation aborted at /app/base_lib/common_mod1.pm line + 88. Compilation failed in require at /app/base_lib/cpath1/common_mod2.pm l +ine 6. BEGIN failed--compilation aborted at /app/base_lib/cpath1/common_mod2. +pm line 6. .. Compilation failed in require at /app/base_lib/cpath1/common_mod2.pm l +ine 20. BEGIN failed--compilation aborted at /app/base_lib//cpath1/common_mod2 +.pm line 20. Compilation failed in require at /Apps/bin/my_script.pl line 18. BEGIN failed--compilation aborted at /Apps/bin/my_script.pl line 18.

We are calling the perl script multiple times with the same parameter but sometimes we see this error. As a workaround for this problem, many of the links on web suggested altering  the order of modules SAX and ParserFactorey names in ParaserDetails.ini. We changed it and moved SAX before SAX::Parser, but still get an error although a different one -

Can't locate object method "new" via package "XML::LibXML::SAX::Parser +" at /usr/lib/perl5/vendor_perl/5.8.5/XML/SAX/ParserFactory.pm line 4 +3. Compilation failed in require at /app/base_lib/mycommon_mod1.pm line 8 +8. BEGIN failed--compilation aborted at /app/base_lib/common_mod1.pm line + 88. Compilation failed in require at /app/base_lib/cpath1/common_mod2.pm l +ine 6. BEGIN failed--compilation aborted at /app/base_lib/cpath1/common_mod2. +pm line 6.

Our product is running on RHEL 4.7.  Along with libxm2 version 2.6.16-12.9 and perl-5.8.5-57.We we are having following perl-XML packages -

perl-XML-Encoding-1.01-26  perl-XML-Twig-3.13-6 perl-XML-NamespaceSupport-1.08-6 perl-XML-Dumper-0.71-2 perl-XML-Grove-0.46alpha-27  perl-XML-LibXML-Common-0.13-8.el4 perl-XML-Parser-2.34-5  perl-libxml-perl-0.07-30 perl-XML-SAX-0.12-7  perl-XML-LibXML-1.58-3.el4 perl-libxml-enno-1.02-31

is this is a known issue with perl ? Also if any of the higher versions resolve this ?

Replies are listed 'Best First'.
Re: Can't locate object method "new" via package "XML::LibXML::SAX"
by Khen1950fx (Canon) on Nov 30, 2012 at 17:48 UTC
    First things first---please post an example snippet of your code.
Re: Can't locate object method "new" via package "XML::LibXML::SAX"
by Anonymous Monk on Dec 01, 2012 at 08:43 UTC

    is this is a known issue with perl ? Also if any of the higher versions resolve this ?

    Doesn't appear to be an issue with perl, you can tell by the way perl gives you a nice error message -- the problem is most likely with your code

      code snnipet line number wise

      Contents of my_script.pl and modules are

      Line# 1 ## Comments .. 11## Comments 12 13 use strict; 14 15 use Getopt::Std; # Command line options processing 16 17 use lib "/app/base_lib/cpath1"; ---->18 use mypkg1::common_mod2 qw(:all);

      Contents of common_mod2.pm are

      Line# 1 package mypkg1::common_mod2; 2 3 ################################################ #commnets .. .. 12 ################################################ 13 14 use strict; 15 use LWP::UserAgent; 16 use HTTP::Request::Common; 17 use XML::Simple; 18 19 use lib "/app/base_lib/cpath1"; ---->20 use mypkg1::common_mod1 qw(:all);

      Contents of common_mod1.pm are

      Line# 1#comments .. 82#comments 83 # Listed here are the other packages 84 use Cwd qw(abs_path); 85 use File::Basename; 86 use Fcntl qw( :flock ); 87 use lib "/app/base_lib/cpath1"; ---->88 use MYLIBS qw( :all ); 89 use MYLogging; 90 use Digest::SHA1 qw(sha1_hex);

      Contents of MYLIBS.pm are

      Line 1 # .. 15 ############################################################## +########## ##### 16 package MYLIBS; 17 18 use strict; 19 use XML::Simple; 20 use Data::Dumper;

        I have posted code snippet for the errors above, any thought what could be the reason for these errors?

        Could it be due to version incompatibility of packages perl(perl-5.8.5-57) , libxml2( package(2.6.16-12.9 ) or perl-xml ?