I just gave 1.4RC3 a quick wirl but I’m seeing some issues. We are
running Jruby/Rails apps that integrate with older Spring/Hibernate
service/models. We’re basically using a
SingleHibernateSessionPerRequest strategy using ThreadLocal bound
hibernate sessions. These apps have been around for quite a while and
are working with Jruby-1.3.1. When I drop in 1.4RC3 I start getting
LazyInitializationExceptions from Hibernate. Tracking down a bit, it
seems to stem from calling ‘sort’ on a Hibernate collection. Below is
some output from Rails console.
-lenny
m = Manuscript.find_by_accode(‘CNR802’)
=> #Java::OrgApsEopModelManuscript::Manuscript:0x465652da
m.lengthChecks
=> #Java::OrgHibernateCollection::PersistentBag:0x1b7163cc
m.lengthChecks.sort_by {|a| a.enteredDate }
=> [#Java::OrgApsEopModelManuscript::LengthCheck:0x40d699ad]
?> m.lengthChecks.sort {|a, b| 0 }
ERROR org.hibernate.LazyInitializationException () - failed to
lazily initialize a collection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize
a collection, no session or session was closed
at
org
.hibernate
.collection
.AbstractPersistentCollection
.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at
org
.hibernate
.collection
.AbstractPersistentCollection
.throwLazyInitializationExceptionIfNotConnected
(AbstractPersistentCollection.java:350)
at
org
.hibernate
.collection
.AbstractPersistentCollection
.initialize(AbstractPersistentCollection.java:343)
at
org
.hibernate
.collection
.AbstractPersistentCollection.write(AbstractPersistentCollection.java:
183)
at org.hibernate.collection.PersistentBag.addAll(PersistentBag.java:
311)
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
.jruby
.javasupport
.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:450)
at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:308)
at
org
.jruby
.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:50)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
147)
at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:155)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
161)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:300)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
118)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
123)
at org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:
64)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.RootNode.interpret(RootNode.java:129)
at
org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:
98)
at org.jruby.RubyKernel.eval(RubyKernel.java:966)
at org.jruby.RubyKernel$s_method_0_3$RUBYFRAMEDINVOKER$eval.call(org/
jruby/RubyKernel$s_method_0_3$RUBYFRAMEDINVOKER$eval.gen)
at
org
.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:
150)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:67)
at
org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:124)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
144)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:67)
at org.jruby.ast.CallManyArgsNode.interpret(CallManyArgsNode.java:59)
at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:210)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
185)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:330)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
189)
at org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.RescueNode.executeBody(RescueNode.java:225)
at
org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:
147)
at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:
317)
at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:251)
at
org.jruby.runtime.InterpretedBlock.yieldSpecific(InterpretedBlock.java:
185)
at org.jruby.runtime.Block.yieldSpecific(Block.java:99)
at org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:192)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
177)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:320)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
158)
at
org
.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:
173)
at
org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:
34)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:
317)
at
org.jruby.runtime.InterpretedBlock.yieldSpecific(InterpretedBlock.java:
216)
at org.jruby.runtime.Block.yieldSpecific(Block.java:117)
at org.jruby.ast.YieldTwoNode.interpret(YieldTwoNode.java:31)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.IfNode.interpret(IfNode.java:117)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.RescueNode.executeBody(RescueNode.java:225)
at
org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:
147)
at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:
317)
at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:268)
at org.jruby.runtime.Block.yield(Block.java:194)
at org.jruby.RubyKernel.loop_1_9(RubyKernel.java:1182)
at org.jruby.RubyKernel$s_method_0_0$RUBYFRAMEDINVOKER
$loop_1_9.call(org/jruby/RubyKernel$s_method_0_0$RUBYFRAMEDINVOKER
$loop_1_9.gen)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:300)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
118)
at
org
.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:
133)
at
org.jruby.ast.FCallNoArgBlockNode.interpret(FCallNoArgBlockNode.java:32)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:
317)
at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:268)
at org.jruby.runtime.Block.yield(Block.java:194)
at org.jruby.RubyKernel.rbCatch(RubyKernel.java:1014)
at org.jruby.RubyKernel$s_method_1_0$RUBYFRAMEDINVOKER
$rbCatch.call(org/jruby/RubyKernel$s_method_1_0$RUBYFRAMEDINVOKER
$rbCatch.gen)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:320)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
158)
at
org
.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:
173)
at
org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:
34)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:155)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
161)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:300)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
118)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
123)
at org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:
64)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:136)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
153)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:290)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
109)
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:61)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:
317)
at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:268)
at org.jruby.runtime.Block.yield(Block.java:194)
at org.jruby.RubyKernel.rbCatch(RubyKernel.java:1014)
at org.jruby.RubyKernel$s_method_1_0$RUBYFRAMEDINVOKER
$rbCatch.call(org/jruby/RubyKernel$s_method_1_0$RUBYFRAMEDINVOKER
$rbCatch.gen)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:320)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
158)
at
org
.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:
173)
at
org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:
34)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org
.jruby
.internal
.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:173)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
169)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:310)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
149)
at Users.Shared.jruby.bin.jirb.file(jirb:19)
at Users.Shared.jruby.bin.jirb.load(jirb)
at org.jruby.Ruby.runScript(Ruby.java:628)
at org.jruby.Ruby.runNormally(Ruby.java:550)
at org.jruby.Ruby.runFromMain(Ruby.java:396)
at org.jruby.Main.run(Main.java:272)
at org.jruby.Main.run(Main.java:117)
at org.jruby.util.ShellLauncher
$ScriptThreadProcess.run(ShellLauncher.java:105)
at java.lang.Thread.run(Thread.java:637)
NativeException: org.hibernate.LazyInitializationException: failed to
lazily initialize a collection, no session or session was closed
from org/hibernate/collection/AbstractPersistentCollection.java:
358:in throwLazyInitializationException' from org/hibernate/collection/AbstractPersistentCollection.java: 350:in
throwLazyInitializationExceptionIfNotConnected’
from org/hibernate/collection/AbstractPersistentCollection.java:
343:in initialize' from org/hibernate/collection/AbstractPersistentCollection.java: 183:in
write’
from org/hibernate/collection/PersistentBag.java:311:in addAll' from /Users/Shared/jruby/lib/ruby/site_ruby/shared/builtin/java/ java.util.rb:105:in
sort’
from (irb):22
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email