-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: need help with jta transaction and servlets
PostPosted: Tue Oct 25, 2005 4:50 pm 
Newbie

Joined: Tue Oct 25, 2005 5:12 am
Posts: 5
hi,

what do i use:

hibernate 3.0.5
jboss 4.0.3SP1
java 5.0
os: linux 64 Bit

mappingfiles,

i can send them by email, but they are ok. I working with them for a while in a SWT Application. Right now we transport the Apllication to ECHO (Web Framework based on Servlets)

my code:


Context context = Bellerophon.getApp().getContext();
UserTransaction transaction = (UserTransaction) context.lookup("java:comp/UserTransaction");
transaction.begin();
SessionFactory sessionFactory = (SessionFactory) context .lookup("java:/hibernate/SessionFactory");

Session session = sessionFactory.getCurrentSession();

//give my model the session
model.setQuery(session.createCriteria(Bin.class));
transaction.commit();

now we render the view and I get:

<stacktrace>

could not initialize proxy - the owning Session was clo
sed

so why does a session commit close my session? And if I don't do this and do a

Session session = sessionFactory.getCurrentSession(); In my model I get a: 2 OPen Session Error.

please help me...

----------------------------------------------------------------------
13:40:51,830 ERROR [[BellerophonServlet]] Servlet.service() for servlet BellerophonServlet threw e
xception
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was clo
sed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.j
ava:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:133)
at edu.ucdavis.genomics.metabolomics.binbase.bdi.types.experiment.sample.Sample$$EnhancerB
yCGLIB$$2325df86.toString(<generated>)
at edu.ucdavis.genomics.metabolomics.binbase.bdi.renderer.impl.ObjectRenderer.render(Unkno
wn Source)
at edu.ucdavis.genomics.metabolomics.binbase.web.table.BinTableCellRenderer.getTableCellRe
ndererComponent(Unknown Source)
at nextapp.echo2.app.Table.doRender(Table.java:309)
at nextapp.echo2.app.Table.validate(Table.java:896)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:254)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:257)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:257)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:257)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:257)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:257)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:257)
at nextapp.echo2.app.ApplicationInstance.doValidation(ApplicationInstance.java:242)
at nextapp.echo2.app.update.UpdateManager.processClientUpdates(UpdateManager.java:95)
at nextapp.echo2.webcontainer.ContainerSynchronizeService.renderUpdate(ContainerSynchroniz
eService.java:366)
at nextapp.echo2.webrender.service.SynchronizeService.service(SynchronizeService.java:281)
at nextapp.echo2.webrender.WebRenderServlet.process(WebRenderServlet.java:264)
at nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:186)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain
.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:17
3)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain
.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:17
3)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.
java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http1
1Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112

-----------------------------------------------------------------------
hibernate-service.xml
<server>

<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate">

<!-- Required services -->
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>

<depends>jboss.jca:service=LocalTxCM,name=BinBaseDS</depends>


<attribute name="DatasourceName">java:/BinBaseDS</attribute>
<attribute name="Dialect">
org.hibernate.dialect.Oracle9Dialect
</attribute>
<attribute name="SessionFactoryName">
java:/hibernate/SessionFactory
</attribute>

<attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
</mbean>

</server>


Top
 Profile  
 
 Post subject: session-per-request
PostPosted: Wed Oct 26, 2005 12:11 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
http://www.hibernate.org/42.html#A6

I suggest moving session management login into servlet filter and implement session-per-request strategy.

It looks like you are trying to use session-per-business transaction strategy, which is just fine, but you neet to make sure that all the properties you(or framework) will access are loaded within the transaction. It pretty much mean that you should have lazy="false" for all collections and associations.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 12:22 am 
Newbie

Joined: Tue Oct 25, 2005 5:12 am
Posts: 5
ok I give it a try tomorrow, with the lazy = false,

is not possible, because I have really bi anotations... so it would end with downloading the hole database, which is impossible...


thx so much and I have a look at the servlet filter.

g.

p.s jta works wounderfull with ejb's but with echo, arg...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.