Hi I'm using Redbridge to integrate my rails site with the shinidig project to 
allow it to act as an open social container. For the most part the code to 
retrieve data is working with my models but when I try to do anything that 
modifies data I get the following exception (Note the *** bold line in the 
exception indicating the line in the script):

NameError: uninitialized constant Arel::Relation::Session
              load_missing_constant at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:506
                      const_missing at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:183
                               each at org/jruby/RubyArray.java:1572
                      const_missing at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181
                            session at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/arel-1.0.1/lib/arel/algebra/relations/relation.rb:10
                             insert at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/arel-1.0.1/lib/arel/algebra/relations/relation.rb:159
                               send at org/jruby/RubyKernel.java:2042
                             insert at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:14
                             create at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:271
                             create at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/timestamp.rb:47
                             create at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:281
              _run_create_callbacks at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:428
                             create at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:281
                   create_or_update at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:247
                   create_or_update at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:277
                _run_save_callbacks at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:438
                   create_or_update at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:277
                               save at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:39
                               save at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/validations.rb:43
                               save at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/attribute_methods/dirty.rb:21
                               save at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:237
  with_transaction_returning_status at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:289
                        transaction at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:139
                        transaction at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:204
  with_transaction_returning_status at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:287
                               save at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:237
      rollback_active_record_state! at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:248
                               save at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:236
                             create at /home/mike/Aptana Studio 3 
Workspace/shindig/java/server/src/main/webapp/WEB-INF/lib/jruby/1.8/gems/activerecord-3.0.0/lib/active_record/base.rb:498
                             *** (root) at <script>:3
May 4, 2011 10:56:24 AM org.apache.shindig.protocol.ApiServlet 
responseItemFromException
INFO: Returning a response error as result of a protocol exception.
org.jruby.embed.EvalFailedException: (NameError) uninitialized constant 
Arel::Relation::Session
    at 
org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:127)
    at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1229)
    at 
org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1222)
    at 
org.apache.shindig.social.sample.spi.zooOpensocialService.createActivity(zooOpensocialService.java:223)
    at 
org.apache.shindig.social.opensocial.service.ActivityHandler.create(ActivityHandler.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at 
org.apache.shindig.protocol.DefaultHandlerRegistry$MethodCaller.call(DefaultHandlerRegistry.java:483)
    at 
org.apache.shindig.protocol.DefaultHandlerRegistry$RpcInvocationHandler.execute(DefaultHandlerRegistry.java:302)
    at 
org.apache.shindig.protocol.DefaultHandlerRegistry$RpcInvocationWrapper.execute(DefaultHandlerRegistry.java:326)
    at 
org.apache.shindig.protocol.JsonRpcServlet.dispatchBatch(JsonRpcServlet.java:186)
    at 
org.apache.shindig.protocol.JsonRpcServlet.service(JsonRpcServlet.java:131)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at 
org.apache.shindig.gadgets.servlet.ETagFilter.doFilter(ETagFilter.java:55)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:242)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at 
org.apache.shindig.auth.AuthenticationServletFilter.callChain(AuthenticationServletFilter.java:130)
    at 
org.apache.shindig.auth.AuthenticationServletFilter.doFilter(AuthenticationServletFilter.java:90)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:242)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:203)
    at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
    at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
    at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
    at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
    at 
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.jruby.exceptions.RaiseException: (NameError) uninitialized 
constant Arel::Relation::Session

The java code to run the function is (Again the bolded *** to indicate where 
the exception occurs) :

public Future<Void> createActivity(UserId userId, GroupId groupId, String 
appId, Set<String> fields, Activity activity, SecurityToken token) throws 
ProtocolException {
        container.put("userId", userId.getUserId(token));
        container.put("appId", appId);
        container.put("fields", fields);
        container.put("activity", activity);
        String script = new StringBuilder()
                .append("a = userId.split('.')\n")
                .append("attribs = {:owner_id=>a[1].to_i, :owner_type=>a[0], 
:source_id=>appId.to_i, :title=>activity.getTitle, :body=>activity.getBody}\n")
                .append("Activity.create(attribs)\n") //***
                .toString();
        container.runScriptlet(script);
        return ImmediateFuture.newInstance(null);
    }

and to initialize jruby and load the rails models I have:

private String basepath;
    private ScriptingContainer container;
    private List loadPaths;

    /**
   * The JSON<->Bean converter
   */
    private BeanConverter converter;
    @Inject
    public zooOpensocialService(@Named("shindig.bean.converter.json")
  BeanConverter converter) throws ScriptException{
        //engine = new ScriptEngineManager().getEngineByName("jruby");
       // System.setProperty("org.jruby.embed.class.path", "Zoo");
        //engine.eval("puts $:.inspect");
        //engine.eval("require 'Zoo/config/environment.rb'");
        this.converter = converter;
        
/********************************************************************************************
         * Note basepath is hacked to static location for now. Find a way to 
use server context or load
         * from configuration file for easier deployment.
         */
        basepath = "/usr/local/tomcat/webapps/ROOT/WEB-INF";
        container = new ScriptingContainer(LocalContextScope.CONCURRENT, 
LocalVariableBehavior.TRANSIENT);
        container.setClassLoader(container.getClass().getClassLoader());
        container.put("load_path", basepath + "/lib/Zoo");
        container.put("gem_path", basepath + "/lib/jruby/1.8");
        container.put("gemfile", basepath + "/lib/Zoo/Gemfile");
        String script =
                "$LOAD_PATH << load_path; ENV['GEM_HOME'] = gem_path; 
ENV['BUNDLE_GEMFILE'] = gemfile\n" +
                "require 'config/environment'\n" +
                "ActionController::Routing::Routes.finalize!";
        container.runScriptlet(script);
    }
                                          

Reply via email to