Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Call jar from Perl/CGI on Apache Server with Linux

by vit (Friar)
on Mar 18, 2013 at 13:50 UTC ( [id://1024042]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks,
I am running my web app using Perl/CGI on Apache server (Not Tomcat) under Linux.
From there I call compiled Java codes as jar files, e.g.
my @ar = `java -jar $path_to_jar/NounPhraseExtractionStandAlone.jar "$ +models_dir" "$text"`;
which works pretty well on my localhost with Apache Tomcat. It also works well when I run it on the external server in a command line like
# perl -e '{@ar = `java -jar $path_to_jar/NounPhraseExtractionStandAlo +ne.jar "$models_dir" "$text"`; print "$a[0]\n"}'
However inside the application it does not work. I checked $path_to_jar using some Perl code instead of Java placed at the same place as jar and it works fine.
Any help/advice is appreciated.

Replies are listed 'Best First'.
Re: Call jar from Perl/CGI on Apache Server with Linux
by blue_cowdawg (Monsignor) on Mar 18, 2013 at 14:11 UTC
        I am running my web app using Perl/CGI on Apache server (Not Tomcat) under Linux.

    Why are you not using a web container like Tomcat? Or JBoss? Or Geronimo?

    This is a rather bizarre implementation to say the least. Not one that I'd recommend in any form of production code. I just did a super search and came up empty, but somewhere in the Monastery catacombs exists a troubleshooting checklist for issues with CGI. Off the top of my head I'd suggest checking the following:

    • File permissions: quite frequently the CGI environment is running as a user other than what you are running as when executing from the command line.
    • Server Logs: Usually a font of information as to "why this ain't working."
    • Put debugging code into your CGI

    To that last point I always recommend you run the following code as a CGI (or some form of it) and quickly remove it from your production environment:

    #!/usr/bin/perl -w use strict; use CGI qw/ :all /; use CGI::Carp qw/ fatalsToBrowser /; print header,start_html; print h1('Environmental Variables'); print ul(map{li($_ . ": " . $ENV{$_})} sort keys %ENV); print h1('CGI Parameters'); print ul(map{li($_ . ": ". param($_))} sort param()); print end_html; exit(0);

    This code will give you some idea of what is going on in you CGI environment.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Call jar from Perl/CGI on Apache Server with Linux
by Anonymous Monk on Mar 18, 2013 at 14:48 UTC
Re: Call jar from Perl/CGI on Apache Server with Linux
by RichardK (Parson) on Mar 18, 2013 at 14:18 UTC

    It might help to look at the status returned from your backticks by printing $?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1024042]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-16 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found