I have a rails app that is communicating with some java services over JMS. I'm caching a few of these objects in memcached on the rails side like so:
@my_objects = MEMCACHE["some_key"] || @service.retrieve_objects
MEMCACHE.set("some_key",@my_objects) if MEMCACHE["some_key"].nil?
where MEMCACHE is
MEMCACHE = MemCache.new(['localhost'], :namespace=>"namespace-#{RAILS_ENV}")
Now, I'm trying to write tests to verify that my memcache is storing these properly and updating properly. Unfortunately when I try to access the objects in the cache I get
MemCache::MemCacheError: Class not found unmarshaling Java type: my/java/package/Classname
What's odd is that referencing the cache in script/console works fine. When I run the app and my unit tests however, I get this error. I didn't think there was any difference between the console and the app when in the same env.
I've included the full stack trace below. It appears to come from deep down in ActiveSupports Memcache client. I've tried all combination of things, even instantiating this particular class right before accessing the cache, but none of it works.
Rails obviously knows about the class as I can retrieve, instantiate and create these java objects directly in my test with no problems, it's only when accessing it from MEMCACHE that I get this error.
Setup
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-13 6586) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java]
Rails 2.2.2
OSX 10.6
Full test stack trace
1) Error:
test_testing_memcache_and_settings(MyTest):
MemCache::MemCacheError: Class not found unmarshaling Java type: my/java/package/Classname
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb:241:in `marshal_load'
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb:241:in `load'
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb:241:in `get'
./test/unit/my_test.rb:54:in `test_testing_memcache_and_settings'
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run_with_callbacks_and_testunit'