Storing connection objects in rails session

Hello,

I am developing a JRuby on Rails project.
I communicate with a backend that delivers me some .jar files which I
can
use to initiate connections, and call Java routines. Basically, I
receive an
Application object upon connection, and all methods are called from this
Application object.

I would like to store these objects in session data, but marshalling
them is
not an option.

I could store the username and password in an (expiring) session -
initiating the connection with these has a very small footprint so I can
do
it for each request - but obviously I do not wish to do store them
legibly.

What are my options? How can I store these Connection objects so they
persist for the user? Or how can I store the passwords anonymously?

I am using Rails 2.3.5.

Thanks for any advice,

View this message in context:
http://old.nabble.com/Storing-connection-objects-in-rails-session-tp27026645p27026645.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Tue, Jan 5, 2010 at 10:07 AM, mmortier [email protected]
wrote:

not an option.

I could store the username and password in an (expiring) session -
initiating the connection with these has a very small footprint so I can do
it for each request - but obviously I do not wish to do store them legibly.

What are my options? How can I store these Connection objects so they
persist for the user? Or how can I store the passwords anonymously?

I am using Rails 2.3.5.

If you’re using Warbler and/or JRuby-Rack, consider the
JavaServletStore. This should allow you to store regular Java objects
in the session, and they will be placed in the servlet session for
repeated use across requests. Set up should be as simple as adding the
following to your session store initializer:

config/initializers/session_store.rb

if defined?($servlet_context)
require ‘action_controller/session/java_servlet_store’
ActionController::Base.session_store = :java_servlet_store
end

Of course, this will also cause any other session values to be stored
in the servlet session.

Let me know if that works for you.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Nick S.-2 wrote:

following to your session store initializer:

That’s exactly what I wanted, thanks! You probably saved me from Spring
horror.


View this message in context:
http://old.nabble.com/Storing-connection-objects-in-rails-session-tp27026645p27055516.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Am Dienstag, 5. Januar 2010 schrieb Nick S.:

end

Of course, this will also cause any other session values to be
stored in the servlet session.

Let me know if that works for you.

Hello Nick,

thank you for this hint, this is exactly what I searched for. But for
some reason I get a problem with the AuthenticityToken.

Do you have an idea how to solve this ?

Thanks, Frank

ActionController::InvalidAuthenticityToken
(ActionController::InvalidAuthenticityToken):
gems/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:79:in
verify_authenticity_token' gems/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:inevaluate_method’
gems/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in
call' gems/gems/actionpack-2.3.5/lib/action_controller/filters.rb:225:incall’
gems/gems/actionpack-2.3.5/lib/action_controller/filters.rb:629:in
run_before_filters' gems/gems/actionpack-2.3.5/lib/action_controller/filters.rb:615:incall_filters’
gems/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in
perform_action_with_filters' gems/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
gems/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' gems/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:inperform_action_with_rescue’
gems/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in
perform_action_with_flash' gems/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:inprocess’
gems/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in
process_with_filters' gems/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:inprocess’
gems/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in
call' gems/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:incall’
gems/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in
dispatch' gems/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in_call’
gems/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in
build_middleware_stack' gems/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:incall’
gems/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in
call' gems/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:incache’
gems/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in
cache' gems/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:incall’
gems/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in
call' gems/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:incall’
gems/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in
call' file:lib/jruby- rack-0.9.5.jar!/action_controller/session/java_servlet_store.rb:48:incall’
gems/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in
call' gems/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:106:incall’
file:lib/jruby-rack-0.9.5.jar!/rack/adapter/rails.rb:35:in
serve_rails' file:lib/jruby-rack-0.9.5.jar!/rack/adapter/rails.rb:40:incall’
file:lib/jruby-rack-0.9.5.jar!/jruby/rack/rails.rb:148:in call' file:lib/jruby-rack-0.9.5.jar!/rack/handler/servlet.rb:18:incall’
:1

/Nick


– To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Frank E.
Managing Director

Bancos GmbH
Hohenzollerndamm 150
14199 Berlin

Phone:    +49 30 884591-0
Fax:      +49 30 884591-100
mail to:  [email protected]
Internet: http://www.bancos.com

Managing Directors: Marco Brueders, Frank E.
Register Court: Amtsgericht Berlin-Charlottenburg
Register No.: HRB 81 138
VAT-ID: DE211841472

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hello, I still get

no marshal_dump is defined for class class SomeJavaClass

Even with the java_servlet_store

Why is that? I cannot marshal the objects? I checked the code for
java_servlet_store and I’m not sure why it needs the marshalling.

Nick S.-2 wrote:

Application object upon connection, and all methods are called from this
legibly.
repeated use across requests. Set up should be as simple as adding the


View this message in context:
http://old.nabble.com/Storing-connection-objects-in-rails-session-tp27026645p27354277.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Fri, Jan 8, 2010 at 4:54 AM, Frank E. [email protected]
wrote:

require ‘action_controller/session/java_servlet_store’

(ActionController::InvalidAuthenticityToken):
gems/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:79:in
`verify_authenticity_token’

Hi Frank, Sorry to get back to you so late. I was able to confirm that
the java servlet store works for me on jruby-rack trunk (0.9.6,
basically) and Rails 2.3.5 using the example/rails app inside the
jruby-rack repository. My suggestion would be to look at your
application controller settings on request forgery protection. The
example app has

config/initializers/session_store.rb

ActionController::Base.session = {
:key => ‘_rails_session’,
:secret => ‘BIG-HEX-KEY’
}

and

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
protect_from_forgery # See
ActionController::RequestForgeryProtection for details

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs