So I have a rails server which accepts json requests. I intend to use it as a server for my iphone app. I get a sign up fail no matter what.
my User Controller is
class UsersController < ApplicationController
respond_to :json
def create
#user = User.new(params[:user])
if #user.save
render :json => {:status => "200", :message => "Signed up successfully"}
else
render :json => {:status => "400", :message => "Failed"}
end
end
end
The url i sent in is
http://localhost:3000/sign_up.json?username=chalami&password=chalami&name=chalami&email=3020#gmail.com
I sent in the url through my browser and not through the app. I wanted to test it through the browser first.
With the posted url I get a
{"status":"400","message":"Failed"}
which should not be happening.
Here is my user.rb
class User < ActiveRecord::Base
attr_accessible :email, :name, :username
attr_accessor :password
before_save :encrypt_password
validates_uniqueness_of :username, :email
validates_presence_of :password, :on => :create
validates_presence_of :email, :username
def encrypt_password
if password.present?
self.password_salt = BCrypt::Engine.generate_salt
self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
end
end
end
My database is empty so it cannot be that either email or username is taken
EDIT 1:
output from rake routes:
sign_up GET /sign_up(.:format) users#create
index GET /index(.:format) users#index
root / users#index
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
Here's the log
Started GET "/sign_up.json?username=chalami&password= [FILTERED]&name=chalami&email=3020#gmail.com" for 127.0.0.1 at 2013-05-28 00:40:44 +0700
Processing by UsersController#create as JSON
Parameters: {"username"=>"chalami", "password"=>"[FILTERED]", "name"=>"chalami", "email"=>"3020#gmail.com"}
(0.0ms) begin transaction
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."username" IS NULL LIMIT 1
User Exists (0.0ms) SELECT 1 AS one FROM "users" WHERE "users"."email" IS NULL LIMIT 1
(0.0ms) rollback transaction
Completed 200 OK in 11ms (Views: 0.2ms | ActiveRecord: 0.6ms)
[2013-05-28 00:40:44] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
EDIT 2::
So as suggested in the comments, I should be using POST instead of GET and I should use curl. I see in my rake routes that there is a POST method with url /users .
so I do a curl on that
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"name":"name","username":"username","email":"email#email.com","password":"app123"}}' http://localhost:3000/users
and I get a whole load of output but could not create a User. Here is the output:
' http://localhost:3000/users
* About to connect() to localhost port 3000 (#0)
* Trying ::1...
* Connection refused
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
> POST /users HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:3000
> Accept: application/json
> Content-type: application/json
> Content-Length: 93
>
* upload completely sent off: 93 out of 93 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/html; charset=utf-8
< Content-Length: 15954
< X-Request-Id: 002af4460c3128e7a78bd10362bcb30f
< X-Runtime: 0.108395
< Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
< Date: Mon, 27 May 2013 17:56:09 GMT
< Connection: Keep-Alive
<
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Action Controller: Exception caught</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
font-family: helvetica, verdana, arial, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
white-space: pre-wrap;
}
a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }
</style>
</head>
<body>
<h1>
ActiveModel::MassAssignmentSecurity::Error
in UsersController#create
</h1>
<pre>Can't mass-assign protected attributes: password</pre>
<p><code>Rails.root: /Users/chalamphongpandey/rails_projects/comboo</code></p>
<div id="traces">
Application Trace |
Framework Trace |
Full Trace
<div id="Application-Trace" style="display: block;">
<pre><code>app/controllers/users_controller.rb:8:in `new'
app/controllers/users_controller.rb:8:in `create'</code></pre>
</div>
<div id="Framework-Trace" style="display: none;">
<pre><code>activemodel (3.2.13) lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
activemodel (3.2.13) lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
activemodel (3.2.13) lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
activemodel (3.2.13) lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
activerecord (3.2.13) lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
activerecord (3.2.13) lib/active_record/base.rb:498:in `initialize'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:414:in `_run__1456629456087302299__process_action__2823567861297586124__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__806197691580144289__call__628697914765895210__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/chalamphongpandey/.rvm/rubies/ruby-1.9.3- p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/chalamphongpandey/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/chalamphongpandey/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'</code></pre>
</div>
<div id="Full-Trace" style="display: none;">
<pre><code>activemodel (3.2.13) lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
activemodel (3.2.13) lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
activemodel (3.2.13) lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
activemodel (3.2.13) lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
activerecord (3.2.13) lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
activerecord (3.2.13) lib/active_record/base.rb:498:in `initialize'
app/controllers/users_controller.rb:8:in `new'
app/controllers/users_controller.rb:8:in `create'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:414:in `_run__1456629456087302299__process_action__2823567861297586124__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__806197691580144289__call__628697914765895210__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/chalamphongpandey/.rvm/rubies/ruby-1.9.3- p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/chalamphongpandey/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/chalamphongpandey/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'</code></pre>
</div>
</div>
<h2 style="margin-top: 30px">Request</h2>
<p><b>Parameters</b>: <pre>{"user"=>{"name"=>"name",
"username"=>"username",
"email"=>"email#email.com",
"password"=>"[FILTERED]"}}</pre></p>
<p>Show session dump</p>
<div id="session_dump" style="display:none"><pre></pre></div>
<p>Show env dump</p>
<div id="env_dump" style="display:none"><pre>GATEWAY_INTERFACE: "CGI/1.1"
HTTP_ACCEPT: "application/json"
REMOTE_ADDR: "127.0.0.1"
REMOTE_HOST: "localhost"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"</pre></div>
<h2 style="margin-top: 30px">Response</h2>
<p><b>Headers</b>: <pre>None</pre></p>
</body>
</html>
* Connection #0 to host localhost left intact
* Closing connection #0
From your error it says that Can't mass-assign protected attributes: password and from the looks of your user model you have made :password an attr_accessor. It is important to understand the differences between the two. The Accessor is a built in thing into Ruby that defies a getter method so that the attribute can be read. Whereas attr_accessible is a ActiveRecord mass-assignment method. The purpose of this is to allow you to pass values to a mass-assginment. You may benefit from reading the following: MassAssignmentSecurity. So what I recommend you to do is change attr_accessor :password to attr_accessible :password
Related
I have created a simple xhtml page with following code (like Primefaces showcase):
<body>
<div>My test</div>
<h:form>
<p:messages showDetail="true"/>
<p:captcha label="Captcha" />
</h:form>
</body>
Loading this page, I get following exceptions:
exception
javax.servlet.ServletException: Expression cannot be null
root cause
javax.el.ELException: Expression cannot be null
My scope is to use captcha component in a form and check if user checked it by a button (submit).
This is the fullstack trace:
Severe: Error Rendering View[/test.xhtml]
javax.el.ELException: Expression cannot be null
at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:172)
at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:237)
at com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:295)
at com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:112)
at org.jboss.weld.util.el.ForwardingExpressionFactory.createValueExpression(ForwardingExpressionFactory.java:53)
at org.jboss.weld.el.WeldExpressionFactory.createValueExpression(WeldExpressionFactory.java:48)
at com.sun.faces.application.ApplicationImpl.evaluateExpressionGet(ApplicationImpl.java:446)
at javax.faces.application.ApplicationWrapper.evaluateExpressionGet(ApplicationWrapper.java:684)
at org.primefaces.component.captcha.CaptchaRenderer.getPublicKey(CaptchaRenderer.java:87)
at org.primefaces.component.captcha.CaptchaRenderer.encodeEnd(CaptchaRenderer.java:50)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:748)
Info: Found ExceptionQueuedEvent: true
Severe: javax.el.ELException: Expression cannot be null
at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:172)
at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:237)
at com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:295)
at com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:112)
at org.jboss.weld.util.el.ForwardingExpressionFactory.createValueExpression(ForwardingExpressionFactory.java:53)
at org.jboss.weld.el.WeldExpressionFactory.createValueExpression(WeldExpressionFactory.java:48)
at com.sun.faces.application.ApplicationImpl.evaluateExpressionGet(ApplicationImpl.java:446)
at javax.faces.application.ApplicationWrapper.evaluateExpressionGet(ApplicationWrapper.java:684)
at org.primefaces.component.captcha.CaptchaRenderer.getPublicKey(CaptchaRenderer.java:87)
at org.primefaces.component.captcha.CaptchaRenderer.encodeEnd(CaptchaRenderer.java:50)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:748)
Warning: StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
You have to go to https://www.google.com/recaptcha/admin
Get a Private and Public key, then register in web.xml with
<context-param>
<param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
<param-value>PUBLIC_KEY</param-value>
</context-param>
<context-param>
<param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
<param-value>PRIVATE_KEY</param-value>
</context-param>
Taking #carlos-ob into account, when using spring-boot-joinfaces-starter, it needs to be in application.yml:
joinfaces:
jsf:
project-stage: Development
state-saving-method: server
#interpret-empty-string-submitted-values-as-null: true
#datetimeconverter-default-timezone-is-system-timezone: true
primefaces:
theme: ultima
font-awesome: true
PUBLIC_CAPTCHA_KEY: PUBLIC_K
PRIVATE_CAPTCHA_KEY: PRIVATE_K
Getting following authentication exception while authenticating against LDAP using spring 4.0 security:
Following is full stack trace of this issue :
org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A8, comment: AcceptSecurityContext error, data 52e, v1db1
at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:191) at
org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:355)
at org.springframework.ldap.core.support.AbstractContextSource.doGetContext(AbstractContextSource.java:139)
at org.springframework.ldap.core.support.AbstractContextSource.getContext(AbstractContextSource.java:130)
at com.globalpay.bvlogin.security.ldap.service.impl.BvLoginCustomBindAuthenticator.bindWithDn(BvLoginCustomBindAuthenticator.java:95)
at com.globalpay.bvlogin.security.ldap.service.impl.BvLoginCustomBindAuthenticator.bindWithDn(BvLoginCustomBindAuthenticator.java:81)
at com.globalpay.bvlogin.security.ldap.service.impl.BvLoginCustomBindAuthenticator.authenticate(BvLoginCustomBindAuthenticator.java:61)
at org.springframework.security.ldap.authentication.LdapAuthenticationProvider.doAuthentication(LdapAuthenticationProvider.java:187)
at org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider.authenticate(AbstractLdapAuthenticationProvider.java:85)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:174)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:199)
at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:124)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:134)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A8, comment: AcceptSecurityContext error, data 52e, v1db1
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3136)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3082)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2883)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2797)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:319)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
at org.springframework.ldap.core.support.LdapContextSource.getDirContextInstance(LdapContextSource.java:42)
at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:343)
... 45 more
------------------------------------------------------------------------------
Following is the configuration in spring-sec-config.xml file:
<security:http use-expressions="true">
<security:intercept-url pattern="/login" access="isAnonymous()" />
<security:intercept-url pattern="/**" access="permitAll()" />
<security:intercept-url pattern="/welcome" access="isAuthenticated()" />
<security:form-login login-page="/"
authentication-failure-url="/?error" login-processing-url="/performLogin"
username-parameter="username" password-parameter="password" />
<!-- <security:logout logout-success-url="/login" /> -->
<security:session-management
session-fixation-protection="migrateSession" invalid-session-url="/performLogout">
<security:concurrency-control
max-sessions="1" error-if-maximum-exceeded="false" />
</security:session-management>
<security:csrf />
<security:headers>
<security:cache-control />
<security:content-type-options />
<security:xss-protection />
<security:frame-options />
<security:hsts />
</security:headers>
</security:http>
<security:authentication-manager alias="ldapAuthManager">
<security:authentication-provider
ref="ldapAuthProvider" />
</security:authentication-manager>
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg
value="ldaps://company.team.san.com:636/DC=team,DC=san,DC=com" />
<property name="userDn" value="cn=service_crs,OU=ServiceAccounts,OU=Administration,DC=team,DC=san,DC=com" />
<property name="password" value="${ldap.adminUserPassword}" />
</bean>
<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg ref="bindAuthenticator" />
<constructor-arg>
<bean
class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
<constructor-arg ref="contextSource" />
<constructor-arg value="ou=ExternalUsers" />
<property name="groupRoleAttribute" value="ou" />
</bean>
</constructor-arg>
</bean>
<bean
class="org.springframework.security.ldap.authentication.BindAuthenticator"
id="bindAuthenticator">
<constructor-arg ref="contextSource" />
<!-- <property name="userSearch" ref="userSearch" /> -->
<property name="userDnPatterns">
<list>
<value>uid={0},OU=ExternalUsers</value>
<!-- <value>uid={0},ou=Administration</value> -->
</list>
</property>
</bean>
<!-- <security:ldap-server ldif="classpath:users.ldif" root="dc=san,dc=org"/> -->
</beans>
Any help to resolve this issue will be appreciated. :)
Thanks in advance.
LDAP: error code 49
means 'invalid credentials', sometimes this error code is also returned (for security reasons) when the entry/account is locked
This is from users_controller.rb
class UsersController < ApplicationController
before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
before_action :correct_user, only: [:edit, :update]
before_action :admin_user, only: [:destroy]
. . .
def destroy
User.find(params[:id]).destroy
flash[:success] = "User deleted"
redirect_to users_url
end
I still don't know where the error is. Can somebody help me, please? Thanks.
I have attached the log from the console. I hope this helps.
Log
AbstractController::ActionNotFound (The action 'destroy' could not be found for UsersController):
actionpack (5.0.0.1) lib/abstract_controller/base.rb:121:in `process'
actionview (5.0.0.1) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.0.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.0.1) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
rack (2.0.1) lib/rack/etag.rb:25:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.1) lib/rack/head.rb:12:in `call'
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.0.0.1) lib/active_record/migration.rb:552:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.1.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.1.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
Routes.rb
Rails.application.routes.draw do
root 'static_pages#home'
get '/help', to: 'static_pages#help', as: :help
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :users
end
Index.html.erb
<% provide(:title, 'All users') %>
<h1>All users</h1>
<%-#= will_paginate #users -%>
<% #users = User.all %>
<ul class="users">
<% #users.each do |user| %>
<%= render #users %>
<% end %>
</ul>
<%-#= will_paginate #users -%>
I have added the log, as requested.
When I try to install jruby modules, I get this mess, always starting with that java.lang.ArrayIndexOutOfBoundsException bit:
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
System.java:-2:in `arraycopy': java.lang.ArrayIndexOutOfBoundsException
from DefaultResolver.java:111:in `makeTime'
from DefaultResolver.java:277:in `create'
from DefaultResolver.java:317:in `handleScalar'
from DefaultResolver.java:435:in `orgHandler'
from DefaultResolver.java:455:in `node_import'
from org/yecht/ruby/DefaultResolver$s_method_1_0$RUBYINVOKER$node_import.gen:65535:in `call'
from CachingCallSite.java:146:in `call'
from RubyLoadHandler.java:39:in `handle'
from Parser.java:300:in `addNode'
from DefaultYAMLParser.java:676:in `yyparse'
from Parser.java:290:in `yechtparse'
from Parser.java:284:in `parse'
from YParser.java:152:in `load'
from org/yecht/ruby/YParser$s_method_0_1$RUBYINVOKER$load.gen:65535:in `call'
from JavaMethod.java:630:in `call'
from DynamicMethod.java:186:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from CallOneArgNode.java:57:in `interpret'
from LocalAsgnNode.java:123:in `interpret'
from NewlineNode.java:104:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from CallOneArgNode.java:57:in `interpret'
from LocalAsgnNode.java:123:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from CallOneArgNode.java:57:in `interpret'
from NewlineNode.java:104:in `interpret'
from RescueNode.java:199:in `executeBody'
from RescueNode.java:118:in `interpretWithJavaExceptions'
from RescueNode.java:110:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from FCallOneArgNode.java:36:in `interpret'
from InstAsgnNode.java:95:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from EnsureNode.java:96:in `interpret'
from BeginNode.java:83:in `interpret'
from NewlineNode.java:104:in `interpret'
from WhenOneArgNode.java:36:in `whenSlowTest'
from WhenOneArgNode.java:46:in `when'
from CaseNode.java:133:in `interpret'
from NewlineNode.java:104:in `interpret'
from InterpretedBlock.java:373:in `evalBlockBody'
from InterpretedBlock.java:346:in `yield'
from InterpretedBlock.java:303:in `yield'
from Block.java:194:in `yield'
from YieldNode.java:112:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedBlock.java:373:in `evalBlockBody'
from InterpretedBlock.java:346:in `yield'
from InterpretedBlock.java:303:in `yield'
from Block.java:194:in `yield'
from RubyKernel.java:1251:in `loop_1_9'
from org/jruby/RubyKernel$s_method_0_0$RUBYFRAMEDINVOKER$loop_1_9.gen:65535:in `call'
from CachingCallSite.java:299:in `cacheAndCall'
from CachingCallSite.java:117:in `callBlock'
from CachingCallSite.java:132:in `callIter'
from FCallNoArgBlockNode.java:32:in `interpret'
from NewlineNode.java:104:in `interpret'
from InterpretedMethod.java:160:in `call'
from DefaultMethod.java:166:in `call'
from CachingCallSite.java:299:in `cacheAndCall'
from CachingCallSite.java:117:in `callBlock'
from CachingCallSite.java:122:in `call'
from CallNoArgBlockNode.java:64:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:242:in `call'
from DefaultMethod.java:198:in `call'
from CachingCallSite.java:339:in `cacheAndCall'
from CachingCallSite.java:197:in `callBlock'
from CachingCallSite.java:202:in `call'
from RubyClass.java:819:in `call'
from DynamicMethod.java:194:in `call'
from WrapperMethod.java:62:in `call'
from CachingCallSite.java:329:in `cacheAndCall'
from CachingCallSite.java:188:in `call'
from FCallTwoArgNode.java:38:in `interpret'
from LocalAsgnNode.java:123:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from EnsureNode.java:96:in `interpret'
from InterpretedMethod.java:242:in `call'
from DefaultMethod.java:198:in `call'
from CachingCallSite.java:339:in `cacheAndCall'
from CachingCallSite.java:197:in `callBlock'
from CachingCallSite.java:202:in `call'
from CallTwoArgBlockPassNode.java:62:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:283:in `call'
from DefaultMethod.java:214:in `call'
from CachingCallSite.java:359:in `cacheAndCall'
from CachingCallSite.java:237:in `callBlock'
from CachingCallSite.java:252:in `callIter'
from CallThreeArgBlockNode.java:64:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:262:in `call'
from DefaultMethod.java:206:in `call'
from CachingCallSite.java:349:in `cacheAndCall'
from CachingCallSite.java:228:in `call'
from FCallThreeArgNode.java:40:in `interpret'
from NewlineNode.java:104:in `interpret'
from InterpretedBlock.java:373:in `evalBlockBody'
from InterpretedBlock.java:346:in `yield'
from InterpretedBlock.java:303:in `yield'
from Block.java:194:in `yield'
from RubyIO.java:1106:in `open'
from RubyKernel.java:283:in `open'
from org/jruby/RubyKernel$s_method_0_2$RUBYFRAMEDINVOKER$open.gen:65535:in `call'
from DynamicMethod.java:198:in `call'
from CachingCallSite.java:339:in `cacheAndCall'
from CachingCallSite.java:197:in `callBlock'
from CachingCallSite.java:212:in `callIter'
from FCallTwoArgBlockNode.java:34:in `interpret'
from NewlineNode.java:104:in `interpret'
from IfNode.java:119:in `interpret'
from IfNode.java:119:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:221:in `call'
from DefaultMethod.java:190:in `call'
from CachingCallSite.java:329:in `cacheAndCall'
from CachingCallSite.java:188:in `call'
from CallTwoArgNode.java:59:in `interpret'
from InstAsgnNode.java:95:in `interpret'
from NewlineNode.java:104:in `interpret'
from RescueNode.java:199:in `executeBody'
from RescueNode.java:118:in `interpretWithJavaExceptions'
from RescueNode.java:110:in `interpret'
from BeginNode.java:83:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:242:in `call'
from DefaultMethod.java:198:in `call'
from CachingCallSite.java:339:in `cacheAndCall'
from CachingCallSite.java:197:in `callBlock'
from CachingCallSite.java:202:in `call'
from RubyClass.java:819:in `call'
from DynamicMethod.java:194:in `call'
from CachingCallSite.java:329:in `cacheAndCall'
from CachingCallSite.java:188:in `call'
from CallTwoArgNode.java:59:in `interpret'
from DAsgnNode.java:110:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedBlock.java:373:in `evalBlockBody'
from InterpretedBlock.java:346:in `yield'
from InterpretedBlock.java:303:in `yield'
from Block.java:194:in `yield'
from RubyArray.java:1630:in `eachCommon'
from RubyArray.java:1637:in `each'
from org/jruby/RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.gen:65535:in `call'
from CachingCallSite.java:299:in `cacheAndCall'
from CachingCallSite.java:117:in `callBlock'
from CachingCallSite.java:122:in `call'
from CallNoArgBlockNode.java:64:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:221:in `call'
from DefaultMethod.java:190:in `call'
from CachingCallSite.java:329:in `cacheAndCall'
from CachingCallSite.java:188:in `call'
from CallTwoArgNode.java:59:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from RescueNode.java:199:in `executeBody'
from RescueNode.java:118:in `interpretWithJavaExceptions'
from RescueNode.java:110:in `interpret'
from BeginNode.java:83:in `interpret'
from NewlineNode.java:104:in `interpret'
from InterpretedBlock.java:373:in `evalBlockBody'
from InterpretedBlock.java:346:in `yield'
from InterpretedBlock.java:303:in `yield'
from Block.java:194:in `yield'
from RubyArray.java:1630:in `eachCommon'
from RubyArray.java:1637:in `each'
from org/jruby/RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.gen:65535:in `call'
from CachingCallSite.java:299:in `cacheAndCall'
from CachingCallSite.java:117:in `callBlock'
from CachingCallSite.java:122:in `call'
from CallNoArgBlockNode.java:64:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:139:in `call'
from DefaultMethod.java:158:in `call'
from CachingCallSite.java:289:in `cacheAndCall'
from CachingCallSite.java:108:in `call'
from VCallNode.java:85:in `interpret'
from NewlineNode.java:104:in `interpret'
from IfNode.java:119:in `interpret'
from IfNode.java:119:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from CallSpecialArgNode.java:67:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from CaseNode.java:138:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from FCallOneArgNode.java:36:in `interpret'
from NewlineNode.java:104:in `interpret'
from RescueNode.java:199:in `executeBody'
from RescueNode.java:118:in `interpretWithJavaExceptions'
from RescueNode.java:110:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from CallOneArgNode.java:57:in `interpret'
from NewlineNode.java:104:in `interpret'
from BlockNode.java:71:in `interpret'
from InterpretedMethod.java:180:in `call'
from DefaultMethod.java:174:in `call'
from CachingCallSite.java:309:in `cacheAndCall'
from CachingCallSite.java:148:in `call'
from gem:24:in `rescue_1$RUBY$__rescue___0'
from gem:23:in `__file__'
from gem:-1:in `load'
from Ruby.java:692:in `runScript'
from Ruby.java:575:in `runNormally'
from Ruby.java:418:in `runFromMain'
from Main.java:286:in `run'
from Main.java:128:in `run'
from Main.java:97:in `main'
Per Unable to install rails with jRuby I tried jruby -S gem install jruby-openssl but I get the same thing. One comment (this one) sounds like it should help but I'm not Ruby enough to understand what he's saying I should do.
Also, that whole thread is from 2011 and I have to assume something has changed since then. Any leads?
Everything works fine until I push to heroku, I gathered that it has to do with diffirent ways mysql and postgres display the boolean values?
I am using Ruby 1.9.2p318 and Rails 3.2.2 with Mysql 5.2.35 on Max OSX
Here is the query I am trying to run
#special_offers = Wine.find(:all, :include => [:inventories], :conditions => ["inventories.special = ? AND inventories.warehouse_id IN (?)", "true", #wharehouses_array], :order => "inventories.updated_at DESC", :limit => 3)
It seems the problem lies with the inventories.special = ?, "true"
This works fine on mysql but not when I push to heroku, wich is using postgres
I have tried replacing the "true" with 1 and "1" and "t" and t and true but nothing seems to work?
UPDATE:
Heroku log file
2012-04-04T14:06:58+00:00 app[web.1]: [2012-04-04 14:06:58] INFO WEBrick 1.3.1
2012-04-04T14:06:58+00:00 app[web.1]: [2012-04-04 14:06:58] INFO WEBrick::HTTPServer#start: pid=1 port=54181
2012-04-04T14:06:58+00:00 app[web.1]: [2012-04-04 14:06:58] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-04-04T14:06:59+00:00 heroku[web.1]: State changed from starting to up
2012-04-04T14:07:01+00:00 app[web.1]: => Booting WEBrick
2012-04-04T14:07:01+00:00 app[web.1]: => Call with -d to detach
2012-04-04T14:07:01+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-04-04T14:07:01+00:00 app[web.1]:
2012-04-04T14:07:01+00:00 app[web.1]: => Rails 3.2.2 application starting in production on http://0.0.0.0:54181
2012-04-04T14:07:01+00:00 app[web.1]:
2012-04-04T14:07:01+00:00 app[web.1]: Started GET "/" for 41.119.121.138 at 2012-04-04 14:07:01 +0000
2012-04-04T14:07:02+00:00 app[web.1]: Processing by HomeController#index as HTML
2012-04-04T14:07:03+00:00 app[web.1]: Rendered partials/_display_wines.html.erb (169.1ms)
2012-04-04T14:07:03+00:00 app[web.1]: Rendered partials/_display_wines.html.erb (0.0ms)
2012-04-04T14:07:03+00:00 app[web.1]: Rendered partials/_display_wines.html.erb (8.1ms)
2012-04-04T14:07:03+00:00 app[web.1]: Rendered home/index.html.erb within layouts/application (259.9ms)
2012-04-04T14:07:03+00:00 app[web.1]: Rendered partials/_header_bar.html.erb (6.5ms)
2012-04-04T14:07:03+00:00 app[web.1]: Rendered partials/_main_links.html.erb (0.3ms)
2012-04-04T14:07:03+00:00 app[web.1]: Rendered partials/_footer.html.erb (4.9ms)
2012-04-04T14:07:03+00:00 app[web.1]: Completed 200 OK in 1081ms (Views: 345.8ms | ActiveRecord: 175.7ms | Solr: 0.0ms)
2012-04-04T14:07:03+00:00 app[web.1]: cache: [GET /] miss
2012-04-04T14:07:03+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=1350ms status=200 bytes=36808
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/javascripts/jquery.js dyno=web.1 queue=0 wait=0ms service=137ms status=304 bytes=0
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/stylesheets/style1.css dyno=web.1 queue=0 wait=0ms service=179ms status=304 bytes=0
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /stylesheets/style1.css] miss
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /javascripts/jquery.js] miss
+00:00 app[web.1]: cache: [GET /javascripts/script1.js] miss
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/javascripts/script1.js dyno=web.1 queue=0 wait=0ms service=187ms status=304 bytes=0
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/javascripts/PIE.js dyno=web.1 queue=0 wait=0ms service=185ms status=304 bytes=0
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/javascripts/rails.js dyno=web.1 queue=0 wait=0ms service=189ms status=304 bytes=0
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /javascripts/PIE.js] miss
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /javascripts/rails.js] miss
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /images/header_tile.png] miss
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/header_tile.png dyno=web.1 queue=0 wait=0ms service=16ms status=304 bytes=0
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /images/none.png] miss
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/none.png dyno=web.1 queue=0 wait=0ms service=35ms status=304 bytes=0
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /images/cybercellar_logo.jpg] miss
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /images/flags.png] miss
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/flags.png dyno=web.1 queue=0 wait=0ms service=96ms status=304 bytes=0
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/cybercellar_logo.jpg dyno=web.1 queue=0 wait=0ms service=84ms status=304 bytes=0
2012-04-04T14:07:04+00:00 app[web.1]: cache: [GET /images/header_login.png] miss
2012-04-04T14:07:04+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/header_login.png dyno=web.1 queue=0 wait=0ms service=44ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/no_wine.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/no_wine.png dyno=web.1 queue=0 wait=0ms service=22ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/buttons2.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/buttons2.png dyno=web.1 queue=0 wait=0ms service=19ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/find_wine_wrap.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/find_wine_wrap.png dyno=web.1 queue=0 wait=0ms service=22ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/comment.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/comment.png dyno=web.1 queue=0 wait=0ms service=5ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/bullet.png] miss
4:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/bullet.png dyno=web.1 queue=0 wait=0ms service=13ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/buttons.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/buttons.png dyno=web.1 queue=0 wait=0ms service=12ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/links_bar.png] miss
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/hr_light.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/hr_light.png dyno=web.1 queue=0 wait=0ms service=12ms status=304 bytes=0
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/links_bar.png dyno=web.1 queue=0 wait=0ms service=17ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/cart_background.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/cart_background.png dyno=web.1 queue=0 wait=0ms service=4ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/home_page_image.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/home_page_image.png dyno=web.1 queue=0 wait=0ms service=6ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/find_wine.png] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/find_wine.png dyno=web.1 queue=0 wait=0ms service=10ms status=304 bytes=0
2012-04-04T14:07:05+00:00 app[web.1]: cache: [GET /images/footer_tile.jpg] miss
2012-04-04T14:07:05+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/footer_tile.jpg dyno=web.1 queue=0 wait=0ms service=7ms status=304 bytes=0
2012-04-04T14:07:06+00:00 app[web.1]: cache: [GET /images/social.png] miss
2012-04-04T14:07:06+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/hr_dark.jpg dyno=web.1 queue=0 wait=0ms service=5ms status=304 bytes=0
2012-04-04T14:07:06+00:00 app[web.1]: cache: [GET /images/hr_dark.jpg] miss
2012-04-04T14:07:06+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/social.png dyno=web.1 queue=0 wait=0ms service=6ms status=304 bytes=0
2012-04-04T14:07:06+00:00 app[web.1]: cache: [GET /images/credit_cards.png] miss
2012-04-04T14:07:06+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/credit_cards.png dyno=web.1 queue=0 wait=0ms service=14ms status=304 bytes=0
2012-04-04T14:07:06+00:00 app[web.1]: cache: [GET /images/money_back.png] miss
2012-04-04T14:07:06+00:00 heroku[router]: GET stormy-fog-6888.herokuapp.com/images/money_back.png dyno=web.1 queue=0 wait=0ms service=5ms status=304 bytes=0
Schema file: for the inventories table
create_table "inventories", :force => true do |t|
t.integer "wine_id"
t.integer "warehouse_id"
t.integer "stock"
t.float "price"
t.integer "quantity_id"
t.timestamp "created_at"
t.timestamp "updated_at"
t.boolean "available", :default => false
t.boolean "discount", :default => false
t.string "markupprofile_id", :limit => 45
t.string "discountprofile_id", :limit => 45
t.float "discount_price"
t.boolean "special", :default => false
end
Use the actual TrueClass, not a string, and Rails will translate it into the correct query for you.
Correct:
"inventories.special = ?", true
Incorrect:
"inventories.special = ?", "true"
It's not throwing an error because the second one still produces a valid query, it's just looking for records where special is a string with the actual t-r-u-e characters in it.