Forum: JRuby Constant cannot be found in the correct rails file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Josh M. (Guest)
on 2009-04-30 18:47
(Received via mailing list)
Hi,

I am trying to write a session store for rails that uses the big table
from
google.  I have written the class and pasted into here.  The problem is
I
keep getting this error when I try to start the dev server:

Caused by: org.jruby.exceptions.RaiseException: Expected
/Users/joshmoore/code/gaej_rails/test/tmp/war/WEB-INF/lib/big_table_servlet_store.rb
to define BigTableServletStore
at
Kernel.raise(/Users/joshmoore/code/gaej_rails/test/tmp/war/WEB-INF/vendor/rails/activesupport/lib/active_support/dependencies.rb:426)
at
ActiveSupport::Dependencies.load_missing_constant(/Users/joshmoore/code/gaej_rails/test/tmp/war/WEB-INF/vendor/rails/activesupport/lib/active_support/dependencies.rb:80)
at
ActiveSupport::Dependencies::ModuleConstMissing.const_missing_with_dependencies(/Users/joshmoore/code/gaej_rails/test/tmp/war/WEB-INF/vendor/rails/activesupport/lib/active_support/dependencies.rb:92)

I do not get it because BigTableServletStore is defined in
big_table_servlet_store.rb (it is the code below).  Does anybody know
what
is going own?

  module ActionController
    module Session
      class BigTableServletStore < AbstractStore
        DATASTORE = Google::DatastoreServiceFactory.datastore_service
        RAILS_SESSION_ENTITY = "__current_rails_session"
        RAILS_SESSION_KEY = "__rails_session_data"

        def initialize(app, options = {})
          # Support old :expires option
          options[:expire_after] ||= options[:expires]

          super


          @session_id = session.session_id
          @key = Google::KeyFactory.create_key(RAILS_SESSION_ENTITY,
@session_id)
          @data = {}

          super
        end

      end

      def marshal(data)
ActiveSupport::Base64.encode64(Marshal.dump(data))
if data end
      def unmarshal(data)
Marshal.load(ActiveSupport::Base64.decode64(data))
if data end

        private
          def get_session(env, sid)
            sid ||= generate_sid
            @key = Google::KeyFactory.create_key(RAILS_SESSION_ENTITY,
sid)

            #begin
              entity = DATASTORE.get(@key)
              if entity.has_property(RAILS_SESSION_STORE)
              session =
unmarshal(eneity.get_property(RAILS_SESSION_KEY)) ||
{}

              session = @pool.get(sid) || {}
            #rescue
            #  session = {}
            #end
            [sid, session]
          end

          def set_session(env, sid, session_data)
            options = env['rack.session.options']
            expiry  = options[:expire_after] || 0

              #begin
              entity = Google::Entity.new(RAILS_SEESION_ENTITY, sid)
              entity.set_property(RAILS_SESSION_KEY, marshal(options))
              DATASTORE.put(entity)

              #@pool.set(sid, session_data, expiry)
              return true
            #rescue
            #  return false
            #end
          end

      #def update
      #  entity = Google::Entity.new(RAILS_SESSION_ENTITY, @session_id)
      #  entity.set_property(RAILS_SESSION_KEY, marshal(@data))
      #  DATASTORE.put(entity)
      #end


      end
    end
  end

module Google
  import com.google.appengine.api.datastore.DatastoreServiceFactory
  import com.google.appengine.api.datastore.Entity
  import com.google.appengine.api.datastore.KeyFactory
  import com.google.appengine.api.datastore.Key
  import com.google.appengine.api.datastore.EntityNotFoundException
end
Charles Oliver N. (Guest)
on 2009-04-30 19:16
(Received via mailing list)
Josh M. wrote:
> Hi,
>
> I am trying to write a session store for rails that uses the big table
> from google.  I have written the class and pasted into here.  The
> problem is I keep getting this error when I try to start the dev server:
>
> Caused by: org.jruby.exceptions.RaiseException: Expected
> /Users/joshmoore/code/gaej_rails/test/tmp/war/WEB-INF/lib/big_table_servlet_store.rb
> to define BigTableServletStore
...
> I do not get it because BigTableServletStore is defined in
> big_table_servlet_store.rb (it is the code below).  Does anybody know
> what is going own?

Well, actually, big_table_servlet_store.rb defines
ActionController::Session::BigTableServletStore. I presume Rails is
doing its dependency magic here, by loading your script and then looking
in some prescribed location for the constant it expected to be defined.
Perhaps that constant should be defined under ActionController:: or at
top-level?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.