You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Manuel Mata <ma...@yahoo.es> on 2007/02/16 20:06:01 UTC

Hibernate Session problem

Hi all. I'm having this trouble with hibernate.

I really dont know why, but i think it is in relation
with continuations or forms.

It works some times but other not, so I'm confused.

I get this exception:

org.apache.cocoon.ProcessingException: Error calling
continuation
	at
file:/C:/cocoon-2.1.9/build/webapp/myapp/flow/bean.js:24:-1
	at <map:call> -
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:111:38
	at <map:serialize type="html"> -
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:184:35
	at <map:transform> -
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:183:59
	at <map:transform type="i18n"> -
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:182:35
	at <map:transform> -
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:181:42
	at
org.apache.cocoon.ProcessingException.throwLocated(ProcessingException.java:144)
	at
org.apache.cocoon.components.flow.javascript.LocationTrackingDebugger.getException(LocationTrackingDebugger.java:131)
	at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:855)
	at
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
	.
	.

[Caused by]
org.hibernate.SessionException: Session is closed!
	at
org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
	at
org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:560)
	at
org.hibernate.impl.SessionImpl.update(SessionImpl.java:552)
	at
org.hibernate.impl.SessionImpl.update(SessionImpl.java:544)
	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:324)
	at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
	at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:1134)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at
org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1591)
	at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:852)
	at
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
	.
	.
	.

It happens in this flowscript function defined in
"flow/beans.js":

function beanForm_form() {
        openHibernateSession();
        var form = new
Form("forms/beanForm.form.xml");
        form.createBinding("forms/beanForm.bind.xml");
// This is a nice feature :-)
        var bean; // The java bean to work with
        var id = cocoon.request.getParameter("id");
        var updating = id != null; // We can be
updating or adding beans
        if(updating){
            bean=hs.find("from Bean where id = " +
id).get(0); // Retrieve from the database
        } else {
            bean = new Bean(); // New bean
        }
        form.load(bean); // Bind the bean to the form
        form.showForm("beanForm.form.template"); //
Shows the form. Another nice feature ;)
        form.save(bean);//Once the form is validated
it is binded to bean
        if(updating){
[24]        hs.update(perfil); // Update the bean
        } else {
[26]        hs.save(perfil); // Store a new bean on
the database
        }
        cocoon.redirectTo("bean.list", true); //
Redirect to a page wich shows a list of beans
}

And the 111 line in sitemap.xmap is a basic
continuation.

        <map:match pattern="*.continue">
[111]       <map:call continuation="{1}"/>
        </map:match>

This is a function which work on both modes "New" and
"Edit" beans, so it fails on lines [24] or [26]
depending what you are doing.

I tried to put another "openHibernateSession()" before
de "if(updating)" but it again work sometimes and
others not.

Do continuations have some strange behaviour against
HibernateFilter, or may be the redirect ?

When I get the error page (with "bean.list" as url), I
press the "go to" button of firefox and I get the bean
list with the new or the modified bean, so I think it
must be working.

I'm really confused, so I'd be glad if some one could
give me a help.

Thx for your reading.


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


[RESOLVED ? ]: Hibernate Session problem

Posted by Manuel Mata <ma...@yahoo.es>.
Hi again. I think the problem was on continuations,
but not a problem at all.

I had to open a new Hibernate session after the
form.show(...) because if the form is not validated it
is shown again, but the hibernate session was closed
by the HibernateFilter. Then when the form was
validated i tried to update or save a bean and throws
the exception with the hibernate session closed.

Another thing was the flush after the update or save.
Dont know why but adding a hs.flush() after the update
or save it works fine. If i dont add the flush i get
the exception again. Why ?

See ya.

> Hi all. I'm having this trouble with hibernate.
> 
> I really dont know why, but i think it is in
> relation
> with continuations or forms.
> 
> It works some times but other not, so I'm confused.
> 
> I get this exception:
> 
> org.apache.cocoon.ProcessingException: Error calling
> continuation
> 	at
>
file:/C:/cocoon-2.1.9/build/webapp/myapp/flow/bean.js:24:-1
> 	at <map:call> -
>
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:111:38
> 	at <map:serialize type="html"> -
>
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:184:35
> 	at <map:transform> -
>
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:183:59
> 	at <map:transform type="i18n"> -
>
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:182:35
> 	at <map:transform> -
>
file:/C:/cocoon-2.1.9/build/webapp/myapp/sitemap.xmap:181:42
> 	at
>
org.apache.cocoon.ProcessingException.throwLocated(ProcessingException.java:144)
> 	at
>
org.apache.cocoon.components.flow.javascript.LocationTrackingDebugger.getException(LocationTrackingDebugger.java:131)
> 	at
>
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:855)
> 	at
>
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
> 	.
> 	.
> 
> [Caused by]
> org.hibernate.SessionException: Session is closed!
> 	at
>
org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
> 	at
>
org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:560)
> 	at
>
org.hibernate.impl.SessionImpl.update(SessionImpl.java:552)
> 	at
>
org.hibernate.impl.SessionImpl.update(SessionImpl.java:544)
> 	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:324)
> 	at
>
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
> 	at
>
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
> 	at
>
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:1134)
> 	at
>
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
> 	at
>
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
> 	at
>
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
> 	at
>
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
> 	at
>
org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1591)
> 	at
>
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:852)
> 	at
>
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
> 	.
> 	.
> 	.
> 
> It happens in this flowscript function defined in
> "flow/beans.js":
> 
> function beanForm_form() {
>         openHibernateSession();
>         var form = new
> Form("forms/beanForm.form.xml");
>        
> form.createBinding("forms/beanForm.bind.xml");
> // This is a nice feature :-)
>         var bean; // The java bean to work with
>         var id = cocoon.request.getParameter("id");
>         var updating = id != null; // We can be
> updating or adding beans
>         if(updating){
>             bean=hs.find("from Bean where id = " +
> id).get(0); // Retrieve from the database
>         } else {
>             bean = new Bean(); // New bean
>         }
>         form.load(bean); // Bind the bean to the
> form
>         form.showForm("beanForm.form.template"); //
> Shows the form. Another nice feature ;)
>         form.save(bean);//Once the form is validated
> it is binded to bean
>         if(updating){
> [24]        hs.update(perfil); // Update the bean
>         } else {
> [26]        hs.save(perfil); // Store a new bean on
> the database
>         }
>         cocoon.redirectTo("bean.list", true); //
> Redirect to a page wich shows a list of beans
> }
> 
> And the 111 line in sitemap.xmap is a basic
> continuation.
> 
>         <map:match pattern="*.continue">
> [111]       <map:call continuation="{1}"/>
>         </map:match>
> 
> This is a function which work on both modes "New"
> and
> "Edit" beans, so it fails on lines [24] or [26]
> depending what you are doing.
> 
> I tried to put another "openHibernateSession()"
> before
> de "if(updating)" but it again work sometimes and
> others not.
> 
> Do continuations have some strange behaviour against
> HibernateFilter, or may be the redirect ?
> 
> When I get the error page (with "bean.list" as url),
> I
> press the "go to" button of firefox and I get the
> bean
> list with the new or the modified bean, so I think
> it
> must be working.
> 
> I'm really confused, so I'd be glad if some one
> could
> give me a help.
> 
> Thx for your reading.
> 
> 
> 		
> ______________________________________________ 
> LLama Gratis a cualquier PC del Mundo. 
> Llamadas a fijos y móviles desde 1 céntimo por
> minuto. 
> http://es.voice.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
> 
> 



		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org