Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Exporter Problem

by syphilis (Canon)
on Feb 17, 2013 at 06:44 UTC ( #1019111=note: print w/ replies, xml ) Need Help??


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 myscript.pl will now produce the same Can't locate object method "new" via package ... error as is produced by loading MyModule.pm.
Is that the case ?

Similarly, running perl /full/path/to/MyModule.pm should produce the same error as running perl myscript.pl (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.

Cheers,
Rob


Comment on Re: Exporter Problem
Select or Download Code
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).

      Cheers,
      Rob

        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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (17)
As of 2014-07-28 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (205 votes), past polls