什么可能导致这个铁路ioerror封闭流?

时间:2009-05-02 22:20:20

标签: ruby-on-rails ruby exception ioerror

我有一个rails应用程序,在开发模式下运行(带有sqlite数据库)。该应用程序的目的是允许用户通过Java客户端上载文件。

如果用户想要上传文件夹,则会以递归方式上传其中的所有文件。如果用户想要上传文件,则文件将正常上传。

这是我收到的错误:


 IOError

    in UploadedFilesController#new

closed stream

以下是应用程序跟踪:


/usr/lib/ruby/1.8/tempfile.rb:167:in `close'
/usr/lib/ruby/1.8/tempfile.rb:167:in `callback'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `call'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `method_added'
app/controllers/uploaded_files_controller.rb:114
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1426:in `recognize'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39

以下是框架跟踪:


/usr/lib/ruby/1.8/tempfile.rb:167:in `close'
/usr/lib/ruby/1.8/tempfile.rb:167:in `callback'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `call'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `method_added'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

以下是完整的跟踪:


/usr/lib/ruby/1.8/tempfile.rb:167:in `close'
/usr/lib/ruby/1.8/tempfile.rb:167:in `callback'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `call'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `method_added'
app/controllers/uploaded_files_controller.rb:114
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1426:in `recognize'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

我不知道为什么会发生这种情况......客户端会在出现此错误之前上传大约15-30个文件(从文件夹到Java客户端)。我正在运行Rails 2.0.2。我是否正在使用sqlite作为数据库在开发模式下运行这一事实?任何帮助将不胜感激 !

谢谢你们!

2 个答案:

答案 0 :(得分:2)

我想我已经弄清楚了,至少我认为我做了(客户端现在继续上传,没有错误)。 从您上传的文件中读取数据后,您还应该关闭它。谁曾想到? :P

答案 1 :(得分:2)

我们的Rails应用程序遇到了同样的问题,虽然简单地关闭文件对象对我们不起作用(我们使用Paperclip,它确实关闭了文件)。我为Tempfile类开发了一个monkeypatch,它已经为我们修复了它,我们将它用作Rails初始化器。

您可以从http://github.com/jwinky/ruby_tempfile_ioerror

抓取它