Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #433 (reopened task)

Opened 10 months ago

Last modified 4 months ago

Uninitialized constant when using 1.5.8 with Rails

Reported by: user Assigned to: nahi
Priority: normal Milestone: 1.5.9
Component: soap4r Version: 1.5
Keywords: Cc:

Description (Last modified by nahi)

When trying to load Rails with soap4r 1.5.8 RC6 installed I receive the following:

/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in `const_missing':NameError: uninitialized constant XSD::NS::KNOWN_TAG

This is caused by soap/ns.rb:18:

  KNOWN_TAG = XSD::NS::KNOWN_TAG.dup.update(
    SOAP::EnvelopeNamespace => 'env'
  )

Commenting this out resolves the issue. No idea as to the root cause. I'm having no problems once it's been commented out.

Change History

09/22/07 09:49:53 changed by nahi

  • status changed from new to closed.
  • resolution set to invalid.
  • milestone changed from undefined to 1.5.8.

Hi,

Please see http://dev.ctor.org/soap4r/wiki#Gem and add the following 2 lines *at the top of* config/environment.rb

require 'rubygems'
gem 'soap4r'

http://groups.google.co.jp/group/soap4r/msg/309fa2f9a23c1471?dmode=source may help you on the same problem about rake + rails.

09/24/07 16:22:23 changed by user

  • status changed from closed to reopened.
  • resolution deleted.

I think this is a more serious problem than it may seem. The issue is that if you install this new SOAP4R gem, it will break every single Rails project that does not have the above changes to environment.rb. This isn't so bad if the project actually uses SOAP4R, but when you have to change every Rails project on the system.... that seems like a problems. A standalone gem should not break other apps that aren't evening using it (IMHO).

While this isn't really a SOAP4R problem so to speak... it's certainly not playing nice with Rails apps. And I'm guessing this Rails autoload "feature" isn't going to change anytime soon...

09/24/07 16:33:18 changed by nahi

  • type changed from defect to enhancement.
  • milestone changed from 1.5.8 to undefined.

09/25/07 08:05:53 changed by user

  • priority changed from normal to high.
  • summary changed from Uninitialized constant when using 1.5.8 RC6 with Rails to Uninitialized constant when using 1.5.8 with Rails.
  • type changed from enhancement to defect.
  • milestone changed from undefined to 1.5.8.

It's even worse than breaking every single Rails project that doesn't have that in the environment.rb

It breaks the "rails" script for generating new Rails applications as well:

$ rails foobar /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in `const_missing': uninitialized constant XSD::NS::KNOWN_TAG (NameError?)

from /opt/local/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/ns.rb:18

09/25/07 08:15:51 changed by nahi

  • priority changed from high to normal.
  • severity changed from critical to normal.
  • milestone changed from 1.5.8 to undefined.

Please claim this to Rails community. There's nothing soap4r can do.

(follow-up: ↓ 20 ) 09/25/07 09:38:19 changed by user

A simple (albeit non-DRY) fix is to change the KNOWN_TAG definition in soap/ns.rb to the following:

class NS < XSD::NS

KNOWN_TAG = {

XSD::Namespace => 'xsd', XSD::InstanceNamespace? => 'xsi', SOAP::EnvelopeNamespace? => 'env'

}

This seems like a trivial case of ActiveSupport? kicking in before everything has properly loaded.

I doubt Rails core is going to do anything about it, and it would require everyone to update Rails in order to fix it.

09/27/07 14:57:51 changed by nahi

  • type changed from defect to task.

Hi,

The problem is caused by;

  • Ruby's feature loading system (Kernel#require), plus
  • RubyGems?' hacking to control the feature loading scheme, plus
  • Rails' hacking to improve performance of the feature loading

It's caused by Rails + RubyGems? and soap4r just hits the problem. For now soap4r is the only module that is bundled with Ruby and released as a gem. When another module such as REXML, yaml and so on will try to create a gem, same kind of problem must be exposed. The only workaround works now is declaring soap4r gem ('gem "soap4r"') before Rails tries to load any features.

10/02/07 14:28:15 changed by nahi

  • status changed from reopened to closed.
  • resolution set to invalid.
  • milestone changed from undefined to 1.5.9.

10/05/07 05:10:49 changed by user

The ruby-talk link seems to be broken, so here is a repost of NaHi's comments on this thread which have some good work-around suggestions:

Eric H. wrote:
>  Seems this was caused by soap4r-1.5.8, removing it and using only 1.5.7
>  fixed the problem. I happened to do a search and found that someone was
>  having problems starting Mongrel if they had 1.5.8 installed so I tried
>  it and viola! it worked.

soap4r-1.5.6, soap4r-1.5.7 did not work as expected, too.

The problem is caused by;

 * Ruby's feature loading system (Kernel#require), plus
 * RubyGems' hacking to control the feature loading scheme, plus
 * Rails' hacking to improve performance of the feature loading

It's caused by ActiveSupport + RubyGems, and soap4r just hits the
problem.  For now soap4r is the only module that is bundled with Ruby
and released as a gem.  When another module such as REXML, yaml and so
on will try to create a gem, same kind of problem must be exposed.

Workaround of this ActiveSupport + RubyGems problem;

 1. declaring soap4r gem ('gem "soap4r"') before Rails tries to load any
    features, or
 2. sudo rm -rf /usr/local/lib/ruby/1.8/{soap,wsdl,xsd}

Regards,
// NaHi

10/05/07 19:48:51 changed by nahi

  • description changed.

Thanks for posting this. It's said that blade.nagaokaut.ac.jp is down by machine crash.

10/10/07 08:29:57 changed by user

Is there any reason you won't modify soap/ns.rb in the way I suggested that avoids the problem?

I'm working with an application being developed by multiple developers and deployed on multiple servers.

This is the bit that's causing it to break:

KNOWN_TAG = XSD::NS::KNOWN_TAG.dup.update(

SOAP::EnvelopeNamespace? => 'env'

)

And all of that seems to be to avoid duplicating the XSD::Namespace => 'xsd' and XSD::InstanceNamespace? => 'xsi' keys in the KNOWN_TAG hash

It would be *extremely* helpful from the purposes of both deployment and maintenance if we didn't have to modify the Ruby installations of every single system we plan on using this application on, or modify every single Rails application to require soap4r in environment.rb

We have applications which do not use SOAP deployed on systems which won't have soap4r installed, for example, and doing an explicit require_gem 'soap4r' in applications we aren't using soap4r on just because we have the soap4r gem installed.

This seems like much ado over two little hash keys...

10/10/07 08:33:46 changed by user

  • status changed from closed to reopened.
  • resolution deleted.

10/10/07 10:27:56 changed by nahi

  • status changed from reopened to closed.
  • resolution set to invalid.

Hi,

There's a clear reason why I can't apply the patch. As I wrote in [ruby-talk:271737] (you can see it at http://dev.ctor.org/soap4r/ticket/433#comment:9 too), patched soap4r-1.5.8, soap4r-1.5.7, and soap4r-1.5.6 all won't work as expected though you've seen no problem yet. Rails are loading xsd/ns.rb in soap4r-1.5.5 and soap/ns.rb in soap4r-1.5.[678] in such an environment.

I cannot support this kind of version mixing environment.

10/11/07 03:56:59 changed by user

  • status changed from closed to reopened.
  • resolution deleted.

I'm not suggesting that in lieu of doing require_gem 'soap4r' before Rails itself loads. I'm suggesting doing that to avoid breaking Rails-related things when soap4r isn't in use.

There won't be a problem with mixed versions as long as the first line of environment.rb is require_gem 'soap4r', correct?

If so, why not make sure the soap4r gem doesn't break Rails when it isn't in use?

10/11/07 07:04:09 changed by nahi

  • status changed from reopened to closed.
  • resolution set to invalid.

Hi,

Because Rails (dependency.rb in ActiveSupport?) wrongly loads mixed versions. It's simply an issue of Rails.

10/13/07 04:56:36 changed by user

  • status changed from closed to reopened.
  • resolution deleted.

In that case, wouldn't it be better to raise an informative exception when a mixed environment is detected, rather than having it fail on this rather obscure error?

10/14/07 09:42:13 changed by nahi

  • status changed from reopened to closed.
  • resolution set to invalid.

I know what you meant but please ask to ruby on ruby-core or rubygems on rubygems-ml. Not related to soap4r.

11/06/07 07:13:35 changed by user

  • status changed from closed to reopened.
  • resolution deleted.

Ruby on Rails is garbage. I am going back to Java. Thanks, Nahi, and the rest of you sadists.

11/09/07 02:23:17 changed by user

This is a pretty serious problem for the Ruby community... anyone coming in right now trying out Ruby for the first time in an enterprise context (more likely than not by way of Rails) is going to walk away in frustration.

Nahi, I would strongly suggest that you put away the argument about who's right vs. who's wrong for the moment, and just accept the patch. You're right of course that in the future this is going to have to be fixed in activesupport, not in soap4r, but please try to be a bit more pragmatic about this. Forcing the Rails team to fix something on their end by pushing into production a show-stopper conflict might not be the most productive (mature?) way to go about this.

(in reply to: ↑ 6 ) 03/28/08 00:20:29 changed by user

FYI, in the example you provided, it printed with a ? at the end of the XSD::InstanceNamespace? like XSD::InstanceNamespace??

Need to remove those question marks for the fix to work...

Replying to user:

A simple (albeit non-DRY) fix is to change the KNOWN_TAG definition in soap/ns.rb to the following: class NS < XSD::NS KNOWN_TAG = { XSD::Namespace => 'xsd', XSD::InstanceNamespace? => 'xsi', SOAP::EnvelopeNamespace? => 'env' } This seems like a trivial case of ActiveSupport? kicking in before everything has properly loaded. I doubt Rails core is going to do anything about it, and it would require everyone to update Rails in order to fix it.