problem with ActiveRecord and PDFWriter

H

hemant

Probably this has been discussed earlier elsewhere.

I am having some problem while using PDFWriter in rails. following
code throws error:

my_table.render_on(pdf)

In short, I get error:

no marshal_dump is defined for class Mutex

RAILS_ROOT: /home/hemant/foo_app/config/..
Application Trace | Framework Trace | Full Trace

/usr/local/lib/site_ruby/1.8/transaction/simple.rb:370:in `dump'
/usr/local/lib/site_ruby/1.8/transaction/simple.rb:370:in `start_transaction'
/usr/local/lib/site_ruby/1.8/transaction/simple/group.rb:89:in
`start_transaction'
/usr/local/lib/site_ruby/1.8/transaction/simple/group.rb:89:in
`start_transaction'
/usr/local/lib/site_ruby/1.8/pdf/simpletable.rb:397:in `render_on'
#{RAILS_ROOT}/app/controllers/analytics_controller.rb:266:in `pdf_download'
#{RAILS_ROOT}/app/controllers/analytics_controller.rb:224:in `pdf_download'
/usr/bin/mongrel_rails:18

It turns out that, people in past also had problems when using
PDFWriter under rails, because rails bundles its own version of
Simple Transaction(simple.rb) package.

But the package bundled with rails is not complete and hence the
libraries that need full blown simple transaction package more or less
break.

I have also tried patching activerecord with this patch:

http://dev.rubyonrails.org/attachme...re-transaction-simple-if-already-loaded.patch

doesn't seem to work. I am also using LoginEngine *code* (i.e just the
code, not the engine itself ,for admin interface). But I have got rid
of most of the transaction statements from the code for the time
being.

So, I am curious..

1. If the problem is in my code?
2. If there is a problem with PDFWriter or AR
3. Or the said patch simply doesn't work

What are my options?
 
A

Austin Ziegler

no marshal_dump is defined for class Mutex

You look like you're doing something threaded. I don't know if that's
Rails doing it for you, but you can't dump either threads or mutexes
in Ruby. You *must* have the latest Transaction::Simple (and Rails
*really* needs to remove it and add the latest version as a
dependency; I'm getting ready to release a new version that's even
more useful and PDF::Writer *will* depend on it moving forward).
1. If the problem is in my code?
2. If there is a problem with PDFWriter or AR
3. Or the said patch simply doesn't work

I suspect 1, 2 (with respect to ActiveRecord bundling
Transaction::Simple; something I've asked them to fix a long time
ago), and 3.

-austin
 
J

Jérôme Loyet

Austin Ziegler a écrit :
You look like you're doing something threaded. I don't know if that's
Rails doing it for you, but you can't dump either threads or mutexes
in Ruby. You *must* have the latest Transaction::Simple (and Rails
*really* needs to remove it and add the latest version as a
dependency; I'm getting ready to release a new version that's even
more useful and PDF::Writer *will* depend on it moving forward).


I suspect 1, 2 (with respect to ActiveRecord bundling
Transaction::Simple; something I've asked them to fix a long time
ago), and 3.

-austin

Hello,

I have exactly the same problem. But the problem doesn't appear if I
test in local with webrick (in development or production environment)
but it appears with apache+mongrel.

All the libraries are in the same version on both configuration (1.1.6
for rails, 1.3.0 for transaction-simple and 1.1.3 for pdf-writer).

I really don't know what to do.
Any help ?

Thanks in advance.
++ Jerome
 
H

hemant

Austin Ziegler a =E9crit :


Hello,

I have exactly the same problem. But the problem doesn't appear if I
test in local with webrick (in development or production environment)
but it appears with apache+mongrel.

All the libraries are in the same version on both configuration (1.1.6
for rails, 1.3.0 for transaction-simple and 1.1.3 for pdf-writer).

I really don't know what to do.
Any help ?

I have tried in vain to patch AR, but it doesn't seem to ( sorry for
violating DRY)
Hmm...there are couple of things which are threaded in my app, but
they don't run within rails. For example:

1. Mongrel itself is threaded.
2. Backgroundrb I am using, which is threaded.
3. I am using a third party charting thingy, which is threaded.

But when I went through code of PDFWriter, it seemed that indeed they
create a mutex and start the transaction. Now, there ain't any mutexes
anywhere in my code and the library I am using is well tucked away. So
only guy creating a mutex was PDFWriter and i suspect PDFWriter is
only trying to dump it.

I am really out of ideas, here... if anyone can help?



--=20
There was only one Road; that it was like a great river: its springs
were at every doorstep, and every path was its tributary.
 
A

Austin Ziegler

But when I went through code of PDFWriter, it seemed that indeed they
create a mutex and start the transaction. Now, there ain't any mutexes
anywhere in my code and the library I am using is well tucked away. So
only guy creating a mutex was PDFWriter and i suspect PDFWriter is
only trying to dump it.

Trust me. PDF::Writer isn't trying to dump a mutex here (this is
something I know well). Have you put a PDF variable in a session or
something like that?

-austin
 
H

hemant

Trust me. PDF::Writer isn't trying to dump a mutex here (this is
something I know well). Have you put a PDF variable in a session or
something like that?

Good point Austin, and honestly I was populating some PDF variables
from session, But then I removed those lines from code and still the
error.

If you don't mind can I send you the code offlist and If you can have a look?
 
A

Austin Ziegler

Good point Austin, and honestly I was populating some PDF variables
from session, But then I removed those lines from code and still the
error.

If you don't mind can I send you the code offlist and If you can have a look?

Sure. Don't expect a quick response, though. I've written one Rails application.

-austin
 
G

Giles Bowkett

in Ruby. You *must* have the latest Transaction::Simple (and Rails
*really* needs to remove it and add the latest version as a
dependency; I'm getting ready to release a new version that's even
more useful and PDF::Writer *will* depend on it moving forward).


I suspect 1, 2 (with respect to ActiveRecord bundling
Transaction::Simple; something I've asked them to fix a long time
ago), and 3.

You could probably distribute a Rails plugin with PDF::Writer as a
workaround. Unless upgrading Transaction::Simple breaks Rails?
 
A

Austin Ziegler

You could probably distribute a Rails plugin with PDF::Writer as a
workaround. Unless upgrading Transaction::Simple breaks Rails?

I will not be doing so. I provide a *Ruby* library. I have told the
Rails folks that they should be using Transaction::Simple library as a
gem, because I guarantee compatibility.

-austin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top