I have a small rails app that was working fine on one system and have moved it to a new system with all the latest code. In my controller I''m calling IO.popen to call some java code but this isn''t working anymore. For example here I''m doing in the controller: displayXml = IO.popen("java -version", "w+") And then I get an error in appache that has me stumped at this point: [Thu Apr 14 23:03:30 2005] [error] [client 10.10.1.48] /usr/local/lib/ruby/site_ruby/1.8/rubyge ms/custom_require.rb:18: command not found: java -version, referer: http://10.10.99.101/filing/ search. Code like this was working with (I think) gem version 0.8.3. New system ha 0.8.8. Thanks for any help you can provide! _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
John- This looks to be like a pathing problem and not a Rails problem. You might want to go ahead and try on this machine doing something like ''which java'' and then explicitly specifying the path in the IO.popen. $ which java /usr/local/bin/java In code: IO.popen("/usr/local/bin/java -version", "w+") Just a thought. Cheers, bs. On 4/14/05, John Marsan <jmarsan-JxUet7QE5mQXhy9q4Lf3Ug@public.gmane.org> wrote:> > I have a small rails app that was working fine on one system and have moved > it to a new system with all the latest code. In my controller I''m calling > IO.popen to call some java code but this isn''t working anymore. > > For example here I''m doing in the controller: > > displayXml = IO.popen("java -version", "w+") > > And then I get an error in appache that has me stumped at this point: > > [Thu Apr 14 23:03:30 2005] [error] [client 10.10.1.48] > /usr/local/lib/ruby/site_ruby/1.8/rubyge > ms/custom_require.rb:18: command not found: java -version, referer: > http://10.10.99.101/filing/ > search. > > Code like this was working with (I think) gem version 0.8.3. New system ha > 0.8.8. > > Thanks for any help you can provide! > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Placing the full path solves part of the problem but the application is still not working correctly (thanks Ben!). It seems that if I used a simple command (like uname) things work fine and if I place options on the command (like uname -a) it still works. This works... displayXml = IO.popen("/bin/uname -a", "w+") But...if I try to run java in here things start to become flakey. For example, "java -version" gives an error (in the apache2 log) and no output is displayed in the browser: [Fri Apr 15 19:34:33 2005] [error] [client 10.10.1.48] java version "1.4.2", referer: http://10.10.99.101/filing/search [Fri Apr 15 19:34:33 2005] [error] [client 10.10.1.48] Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2), referer: http://10.10.99.101/filing/search [Fri Apr 15 19:34:33 2005] [error] [client 10.10.1.48] Classic VM (build 1.4.2, J2RE 1.4.2 IBM build cxia321420-20040626 (JIT enabled: jitc)), referer: http://10.10.99.101/filing/search Code for above failure from the controller: displayXml = IO.popen("/usr/lib/java/jre/bin/java -version", "w+") Which is a bit strange. Also what I really want to do is use Java to run Saxon to apply an XSLT stylesheet to a document that needs some transforming...this behaves really oddly (at least to me) in that it misses my classpath option on the command line but does seem to find the call to the stylesheet but since the classpath is "missing" the thing breaks. And this is the error I see: [Fri Apr 15 19:38:03 2005] [error] [client 10.10.1.48] The java class is not found: com/icl/saxon/StyleSheet, referer: http://10.10.99.101/filing/search The failing code for the above: displayXml = IO.popen("/usr/lib/java/jre/bin/java \-classpath /usr/local/saxon/saxon.jar com.icl.saxon.StyleSheet /usr/local/rails/edgar/data/#{@xmlDoc} /usr/local/rails/edgar/data/xmlToHtml.xsl", "w+") (BTW - is there a way to do XSLT transforms in rails and/or ruby so I can stop the java gymnastics I''m currently trying to do?) Thanks again for the help! John ----- Original Message ----- From: "Ben Schumacher" <benschumacher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Friday, April 15, 2005 12:44 AM Subject: Re: [Rails] New Problem With IO.popen? John- This looks to be like a pathing problem and not a Rails problem. You might want to go ahead and try on this machine doing something like ''which java'' and then explicitly specifying the path in the IO.popen. $ which java /usr/local/bin/java In code: IO.popen("/usr/local/bin/java -version", "w+") Just a thought. Cheers, bs. On 4/14/05, John Marsan <jmarsan-JxUet7QE5mQXhy9q4Lf3Ug@public.gmane.org> wrote:> > I have a small rails app that was working fine on one system and have > moved > it to a new system with all the latest code. In my controller I''m calling > IO.popen to call some java code but this isn''t working anymore. > > For example here I''m doing in the controller: > > displayXml = IO.popen("java -version", "w+") > > And then I get an error in appache that has me stumped at this point: > > [Thu Apr 14 23:03:30 2005] [error] [client 10.10.1.48] > /usr/local/lib/ruby/site_ruby/1.8/rubyge > ms/custom_require.rb:18: command not found: java -version, referer: > http://10.10.99.101/filing/ > search. > > Code like this was working with (I think) gem version 0.8.3. New system > ha > 0.8.8. > > Thanks for any help you can provide! > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.11 - Release Date: 4/14/2005
> Code for above failure from the controller: displayXml > IO.popen("/usr/lib/java/jre/bin/java -version", "w+")When running this from the command line for ruby, that works fine for me. Does it you?> > Which is a bit strange. Also what I really want to do is use Java to run > Saxon to apply an XSLT stylesheet to a document that needs some > transforming...this behaves really oddly (at least to me) in that it misses > my classpath option on the command line but does seem to find the call to > the stylesheet but since the classpath is "missing" the thing breaks. And > this is the error I see: > > [Fri Apr 15 19:38:03 2005] [error] [client 10.10.1.48] The java class is not > found: com/icl/saxon/StyleSheet, referer: http://10.10.99.101/filing/search > > The failing code for the above: displayXml > IO.popen("/usr/lib/java/jre/bin/java \-classpath /usr/local/saxon/saxon.jar > com.icl.saxon.StyleSheet /usr/local/rails/edgar/data/#{@xmlDoc} > /usr/local/rails/edgar/data/xmlToHtml.xsl", "w+")2 things to check: * Why the "\" preceding your classpath parameter? * Silly, but is com/icl/saxon/StyleSheet.class in fact, IN the /usr/local/saxon/saxon.jar? (And is the jar (and its directory tree) readable by whatever process rails is running under?)> > (BTW - is there a way to do XSLT transforms in rails and/or ruby so I can > stop the java gymnastics I''m currently trying to do?) > > Thanks again for the help! > > John > > > ----- Original Message ----- > From: "Ben Schumacher" <benschumacher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Sent: Friday, April 15, 2005 12:44 AM > Subject: Re: [Rails] New Problem With IO.popen? > > John- > > This looks to be like a pathing problem and not a Rails problem. You > might want to go ahead and try on this machine doing something like > ''which java'' and then explicitly specifying the path in the IO.popen. > > $ which java > /usr/local/bin/java > > In code: > > IO.popen("/usr/local/bin/java -version", "w+") > > Just a thought. > > Cheers, > > bs. > > On 4/14/05, John Marsan <jmarsan-JxUet7QE5mQXhy9q4Lf3Ug@public.gmane.org> wrote: > > > > I have a small rails app that was working fine on one system and have > > moved > > it to a new system with all the latest code. In my controller I''m calling > > IO.popen to call some java code but this isn''t working anymore. > > > > For example here I''m doing in the controller: > > > > displayXml = IO.popen("java -version", "w+") > > > > And then I get an error in appache that has me stumped at this point: > > > > [Thu Apr 14 23:03:30 2005] [error] [client 10.10.1.48] > > /usr/local/lib/ruby/site_ruby/1.8/rubyge > > ms/custom_require.rb:18: command not found: java -version, referer: > > http://10.10.99.101/filing/ > > search. > > > > Code like this was working with (I think) gem version 0.8.3. New system > > ha > > 0.8.8. > > > > Thanks for any help you can provide! > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.308 / Virus Database: 266.9.11 - Release Date: 4/14/2005 > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Problem solved - it was as suggested by Micahael at the end of his comments a permissions problem - the jar file I was trying to access from within the controller was not accessbile to the apache process. Thanks again for the help.>----- Original Message ----- >From: "Michael Campbell" <michael.campbell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >Sent: Saturday, April 16, 2005 6:19 AM >Subject: Re: [Rails] New Problem With IO.popen? >>> Code for above failure from the controller: displayXml >> IO.popen("/usr/lib/java/jre/bin/java -version", "w+") > >When running this from the command line for ruby, that works fine for >me. Does it you?Yes.>> >> Which is a bit strange. Also what I really want to do is use Java to run >> Saxon to apply an XSLT stylesheet to a document that needs some >> transforming...this behaves really oddly (at least to me) in that it >> misses >> my classpath option on the command line but does seem to find the call to >> the stylesheet but since the classpath is "missing" the thing breaks. >> And >> this is the error I see: >> >> [Fri Apr 15 19:38:03 2005] [error] [client 10.10.1.48] The java class is >> not >> found: com/icl/saxon/StyleSheet, referer: >> http://10.10.99.101/filing/search >> >> The failing code for the above: displayXml >> IO.popen("/usr/lib/java/jre/bin/java \-classpath >> /usr/local/saxon/saxon.jar >> com.icl.saxon.StyleSheet /usr/local/rails/edgar/data/#{@xmlDoc} >> /usr/local/rails/edgar/data/xmlToHtml.xsl", "w+") > >2 things to check: > * Why the "\" preceding your classpath parameter?Left over from my earlier troubleshooting attempts. Didn''t seem to have any affect positive or negative.>* Silly, but is com/icl/saxon/StyleSheet.class in fact, IN the >/usr/local/saxon/saxon.jar? (And is the jar (and its directory tree) >readable by whatever process rails is running under?)Ahh - jar file not readable by apache! John
On 4/16/05, John Marsan <jmarsan-JxUet7QE5mQXhy9q4Lf3Ug@public.gmane.org> wrote:> > Problem solved - it was as suggested by Micahael at the end of his comments > a permissions problem - the jar file I was trying to access from within the > controller was not accessbile to the apache process. Thanks again for the > help.Excellent, glad I could help!