Kevin McNamee
2007-May-29 07:36 UTC
undefined method `define_a_column'' for class `OCI8::Cursor''
Hi, Environment: Solaris 10, Orale 10g, Apache 2.2, Ruby 1.8.4, Rails 1.2.3, Ruby OCI8 1.0.0-rc2 As soon as I compiled and installed the Ruby/OCI8 interface, I got the following error from my application: ========================[notice] mod_fcgid: call /export/home/invido/invido/portal2/public/ dispatch.fcgi with wrapper /usr/local/bin/ruby /export/home/invido/ invido/portal2/public/dispatch.fcgi /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/oracle_adapter.rb:536: undefined method `define_a_column'' for class `OCI8::Cursor'' (NameError) ... ======================== Looking around, I got a lot of hits pointing to environment settings (LD_LIBRARY_PATH, etc.), for example: http://dev.rubyonrails.org/ticket/1027 However, none of this had any effect and in any case this seems like this is a purely ruby problem. I mean it is missing a method somewhere. Looking at the error in question: =========================... class OCI8 #:nodoc: # This OCI8 patch may not longer be required with the upcoming # release of version 0.2. class Cursor #:nodoc: alias :define_a_column_pre_ar :define_a_column # <--- line 536 def define_a_column(i) case do_ocicall(@ctx) { @parms[i - 1].attrGet(OCI_ATTR_DATA_TYPE) } when 8 : @stmt.defineByPos(i, String, 65535) # Read LONG values when 187 : @stmt.defineByPos(i, OraDate) # Read TIMESTAMP values when 108 if @parms[i - 1].attrGet(OCI_ATTR_TYPE_NAME) == ''XMLTYPE'' @stmt.defineByPos(i, String, 65535) else raise ''unsupported datatype'' end else define_a_column_pre_ar i end end end ... ========================== It looks like it is redefining a function from the original Cursor class in /usr/local/lib/ruby/site_ruby/1.8/oci8.rb but it seems to be failing to find the "define_a_column" method. I am really stuck here. What can I do? Much appreciated, Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Kevin McNamee
2007-May-29 11:15 UTC
Re: undefined method `define_a_column'' for class `OCI8::Cursor''
Hi, I should have said that I think that this is purely a Rails problem, since the ruby one-liner works fine:> LD_LIBRARY_PATH=/usr/local/instantclient_10_2 \ruby -r oci8 -e '' OCI8.new("XXXX", "YYYY", "//localhost/sid").exec("select * from release_states") do |r| puts r.join(","); end '' /Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael A. Schoen
2007-May-29 16:47 UTC
Re: undefined method `define_a_column'' for class `OCI8::Cursor''
Kevin McNamee wrote:> It looks like it is redefining a function from the original Cursor > class in /usr/local/lib/ruby/site_ruby/1.8/oci8.rb but it seems to be > failing to find the "define_a_column" method. > > I am really stuck here. What can I do?This is a library path problem. The solution varies by platform, but you need to have your environment set up such that you can successfully connect to your Oracle database using sqlplus. If you can do that, you won''t have this error. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Kevin McNamee
2007-May-29 18:59 UTC
Re: undefined method `define_a_column'' for class `OCI8::Cursor''
I can run sqlplus as follows: ========================> LD_LIBRARY_PATH=/usr/local/instantclient_10_2 /usr/local/instantclient_10_2/sqlplus SQL*Plus: Release 10.2.0.3.0 - Production on Tue May 29 20:53:44 2007 Copyright (c) 1982, 2006, Oracle. All Rights Reserved. Enter user-name: ======================== This is how my httpd.conf looks: ========================<VirtualHost *:80> ServerAdmin webmaster@acme.com DocumentRoot /home/username/myapp/public ServerName myapp.acme.com ServerAlias myapp ErrorLog logs/myapp.acme.com-error_log CustomLog logs/myapp.acme.com-access_log common # Taken from http://fastcgi.coremail.cn/configuration.htm#Ruby # and modified for Apache 2.2 #SocketPath /tmp/fcgid_sock #SharememPath /tmp/fcgid_shm SetEnv RAILS_ENV production SetEnv LD_LIBRARY_PATH /usr/local/instantclient_10_2 <Directory /export/home/invido/invido/portal2/public> Options ExecCGI FollowSymLinks AllowOverride AuthConfig Indexes Limit FileInfo Options Order allow,deny Allow from all AddHandler fcgid-script .fcgi FCGIWrapper "/usr/local/bin/ruby /home/username/myapp/public/ dispatch.fcgi" .fcgi RewriteEngine On RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </Directory> </VirtualHost> ======================== I restart Apache but still get "define_a_column" error --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Kevin McNamee
2007-May-29 20:03 UTC
Re: undefined method `define_a_column'' for class `OCI8::Cursor''
OK, so I solved the problem. Yippee! My Apache conf was incorrect. ========================<IfModule mod_fcgid.c> DefaultInitEnv LD_LIBRARY_PATH /usr/local/instantclient_10_2 DefaultInitEnv TNS_ADMIN /etc/oracle </IfModule> <VirtualHost *:80> ServerAdmin webmas...@acme.com DocumentRoot /home/username/myapp/public ServerName myapp.acme.com ServerAlias myapp ErrorLog logs/myapp.acme.com-error_log CustomLog logs/myapp.acme.com-access_log common # Taken from http://fastcgi.coremail.cn/configuration.htm#Ruby # and modified for Apache 2.2 #SocketPath /tmp/fcgid_sock #SharememPath /tmp/fcgid_shm DefaultInitEnv RAILS_ENV production <Directory /home/username/myapp/public> Options ExecCGI FollowSymLinks AllowOverride AuthConfig Indexes Limit FileInfo Options Order allow,deny Allow from all AddHandler fcgid-script .fcgi FCGIWrapper "/usr/local/bin/ruby /home/username/myapp/public/ dispatch.fcgi" .fcgi RewriteEngine On RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </Directory> </VirtualHost> ======================== The "SetEnv" directives had no effect. The correct directive to use is "DefaultInitEnv". Plus the following configuration information from http://wiki.rubyonrails.com/rails/pages/HowToUseOracleWithFastCGI Thanks for your patience! /Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---