Welcome Guest | Login

soap4r causes Application Error?

I'm having a problem starting my rails app.  The app uses a SOAP interface to another web service, and I've verified that it works on the command line and also from the rails console.  The following lines are in my config/environment.rb file, I get the infamous Application Error whenever the third line (driver.rb) is included.

.
.
.
# FOR PDB WEB SERVICES
require 'rubygems'
gem 'soap4r'
require 'driver.rb'
.
.
.

Again, the error occurs whenever the require 'driver.rb' line is included.  That file resides at my RAILS_ROOT, and starts with:

require 'default.rb'
require 'MappingRegistry.rb'
require 'soap/rpc/driver'
.
.
.

The files default.rb and MappingRegistry.rb are also in my RAILS_ROOT.  Any thoughts why this works from the console but not as part of a FCGI process?

-cal

2007-09-12 09:39 PM

When you checked your Rails console did you load it in both development and production mode?  I'd be curious to see the console session of the following (don't have any of these lines in your environment.rb already).

>>require 'rubygems'
>>gem 'soap4r'
>>require 'driver.rb'


Can you paste the result of these from both a development and production mode, along with the full trace error that you get in your production.log when you try to load your app from a browser?  

Cheers,
~William

2007-09-13 05:11 AM

The console output in development mode shows the problem, I think.  Here's the output:

me@host [~/myapp]$ ./script/console development
Loading development environment.
require>> require
>> require 'rubygems'
=> []
>> gem 'soap4r'
=> false
>> require 'driver.rb'
NameError: uninitialized constant SOAP::Mapping::EncodedRegistry
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:263:in `load_missing_constant'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing'
       from ./MappingRegistry.rb:5
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./driver.rb:2
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from (irb):3
>> quit
I was reminded of a fix I needed to make on my development machine, and found it with the help of google: http://groups.google.com/group/soap4r/browse_thread/thread/17175f520bfc520f

I suppose I need to submit a request to have the appropriate file changed (/usr/local/lib/1.8/soap/mapping.rb)?

-cal

2007-09-13 06:22 AM

Hello,

Could you please try now. I have made the required changes. Thank you

2007-09-13 07:02 AM

HostingRails Support
Hello,

Could you please try now. I have made the required changes. Thank you

2007-09-13 07:02 AM

HostingRails Support
Thanks, Kumar.  But I still have the same problem -- it seems that /usr/local/lib/ruby/1.8/soap/mapping.rb has the new line, but it's commented out.  If you remove the leading #, I'll give it another try.

-cal

2007-09-13 10:58 AM

Oh ! I am sorry, I have removed it.

2007-09-13 11:10 AM

HostingRails Support
Thanks, but now it seems more broken than before.  Now, when I comment out the three require lines in my config/environment.rb, and run the console in development mode, I get the following two errors just as the console starts:

Loading development environment.
./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:477:in `const_missing':NameError: uninitialized constant SOAP::Mapping::EncodedRegistry::RegistrySupport
./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:477:in `const_missing':NameError: uninitialized constant ApplicationController::LoginSystem
>> require 'rubygems'
=> []
>> gem 'soap4r'
=> false
>> require 'driver.rb'
NameError: uninitialized constant SOAP::Mapping::EncodedRegistry::RegistrySupport
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:477:in `const_missing'
       from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.7/lib/soap/mapping/encodedregistry.rb:51
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from /usr/local/lib/ruby/gems/1.8/gems/soap4r-1.5.7/lib/soap/mapping.rb:11
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./MappingRegistry.rb:2
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./driver.rb:2
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
       from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
       from (irb):3>>
?>
I'm confused.  Any thought out there in hostingrails-land?

-cal

2007-09-13 11:23 AM

Hello,

Okay, I have reverted the changes. Could you please try freezing the soap gems to your home directory and check this. You can follow the tutorial link:

http://www.hostingrails.com/forums/wiki_thread/2

2007-09-13 11:48 AM

HostingRails Support
That's exactly what I did earlier today: I made a ~/.gems dir, set GEM_HOME and GEM_PATH accordingly, and downloaded the latest soap4r gem.  Incidentally, this looks to be a build from Tuesday.  Notably, the lib/soap/mapping.rb file contains lines for "soap/mapping/encodedregistry" and another one (sorry, I don't have ssh access at the moment, so I can't be specific).

I unpacked the latest soap4r gem into RAILS_ROOT/vendor.  After commenting out the require lines from RAILS_ROOT/config/environment.rb, I ran the console and require'd the files manually.  And it worked!

But...it still didn't work in my Rails app one I uncommented those lines and killall'd the dispatch.fcgi process (again, running using FCGI).  I tried a few things: referring to the soap4r gem using its relative path (require 'vendor/soap4r-1.5.7-90.200....'), and setting ENV['GEM_PATH'] from within environment.rb.  Clearly I'm missing something.  I suspect it's a simple matter, but I can't quite grasp it.

I'll be able to try again in a few hours.  I'd love to hear if you have any suggestions.

-cal

2007-09-13 02:00 PM

To summarize, I have unpacked the latest soap4r gem into RAILS_ROOT/vendor (it's called soap4r-1.5.7.90.20070911).  When I comment out the require and gem lines in config/environment.rb, and run './script/console development', here's the output:

me@host [~/myapp]$ ./script/console development
Loading development environment.
>> require 'rubygems'
=> []
>> gem 'soap4r'
=> false
>> require 'driver.rb'
=> ["PdbWebService"]
>> quit
No problems.  When I add these lines at the bottom of my config/environment.rb file, I get an Application Error.  This error only occurs if "require 'driver.rb'" is present.

I don't understand the difference in how rails is loaded under fcgi versus the console.  Woudl it make a difference if I were running webrick or mongrel?

-cal

2007-09-13 05:34 PM

I don't think it'll be different in mongrel or webrick.
Btw what do you see when you load production environment to console ?
./script/console production

Thanks

2007-09-15 01:34 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up.