in reply to Exporter Problem

Lingua::StanfordCoreNLP uses Inline::Java and I wonder if that complicates things somehow. (I don't really see how ... but I don't know much about the way Inline::Java works.)

If you take your "Script Code" and insert package MyModule; at the very beginning of that file, then the "Script Code" is now essentially the same as "My Module Code".
Having made that change to the "Script Code" one would therefore expect that running perl will now produce the same Can't locate object method "new" via package ... error as is produced by loading
Is that the case ?

Similarly, running perl /full/path/to/ should produce the same error as running perl (for the modified "Script Code").

If you can test that out, it would help us determine whether Inline::Java is, in fact, the source of the problem.


Replies are listed 'Best First'.
Re^2: Exporter Problem
by osler (Sexton) on Feb 17, 2013 at 13:40 UTC

    yes, when I write package at the top of the script I get the same error and when I run the pm file like a script I get the error. It appears to be related to the namespace of my package somehow breaking the creation of Lingua::StanfordCoreNLP subclasses.

Re^2: Exporter Problem
by osler (Sexton) on Feb 17, 2013 at 16:44 UTC
    This is definitely related to Inline not Exporter which is what I originally thought. I see now that the subclasses are defined by Inline. So I need to understand how Inline exports into the calling class' namespace.
      This is definitely related to Inline not Exporter

      It's interesting that Inline::Java can have such an effect.

      Try starting another perlmonks thread under a more appropriate title. That might flush out someone who has an understanding of Inline::Java (and perhaps even a solution for you.)
      Also, you could try a post to the Inline mailing list. I think the Inline::Java author is subscribed to that mailing list, but you could cc him just in case he's not. (You'll find an email address for him here).


        Thanks for the recommendation. I think the issue is that Lingua::StanfordCoreNLP has the java code in the __DATA__ section of the PM file. My understanding is that the __DATA__ section is not read until runtime so the perl bindings to the java classes and methods can't happen until runtime. I was trying to create a Lingua::StanfordCoreNLP::Pipeline object in my package to store it as a package global. Doing this at that time, the Pipeline object is not defined yet.

        My work around is to create the pipeline object at runtime and pass it along to the new method of my package.

        I am also having trouble with using inline::java in a mod_perl environment -- there is information about this problem in the docs. I will pursue an Inline::Java thread if I run into more problems.

        Thanks for your help!