-->
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.  [ 2 posts ] 
Author Message
 Post subject: Session is closing and I don't understand why
PostPosted: Tue Sep 14, 2004 8:58 pm 
Beginner
Beginner

Joined: Mon May 24, 2004 7:39 pm
Posts: 37
Location: Charlotte
I must be missing something very stupid but I'm making a few session calls and then closing the session at the end. After making the first session call, the session seems to be automatically closing and I don't understand why. Can anybody assist with me with this? Thank you very much.


Hibernate version: 2.1.6

Code between sessionFactory.openSession() and session.close():
Session session = null;
Transaction transaction = null;
try {
session = MessageBoxDAO.getInstance().createNewSession();
MimeMessage message = mail.getMessage();
String name = getName(message.getHeader("From")[0]);
String emailAddress = getEmail(message.getHeader("From")[0]);
String subject = message.getHeader("Subject")[0];
String bodyText = IOUtils.toString(message.getInputStream());
String boxNumber = getBoxNumber(emailAddress);
System.out.println(session.isOpen());
MessageBox box = (MessageBox) session.load(MessageBox.class, new Long(boxNumber));
System.out.println(session.isOpen());
if (null != box) {
// THE LINE BELOW IS WHERE THE EXCEPTION OCCURS
transaction = session.beginTransaction();
EmailMessage emailMessage = new EmailMessage();
emailMessage.setBody(bodyText);
emailMessage.setCreatedDate(new Date());
emailMessage.setFromAddress(emailAddress);
emailMessage.setMessageBox(box);
emailMessage.setSubject(subject);
session.save(emailMessage);
box.setLastMessageCreatedDate(new Date());
session.update(box);
transaction.commit();
}
}
finally {
if (null != transaction) transaction.rollback();
if (null != session) session.close();
}


Full stack trace of any exception that occurs:

Name and version of the database you are using: MySQL 4.0.20

Debug level Hibernate log excerpt:
17255 [Spool Thread #0] INFO com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener - JavaGroups clustering support started s
uccessfully
17255 [Spool Thread #0] DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - get called (key=1.com.myadbox.bo.ServiceLevel)
17255 [Spool Thread #0] DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - persistRetrieve called (key=1.com.myadbox.bo.Serv
iceLevel)
17315 [Spool Thread #0] DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - persistStore called (key=1.com.myadbox.bo.Service
Level)
17325 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [com.myadbox.bo.ServiceLevel#1]
17325 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [com.myadbox.bo.MessageBox#1]
17325 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - loading [com.myadbox.bo.ServiceLevel#1]
17325 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [com.myadbox.bo.ServiceLevel#1]
17325 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [com.myadbox.bo.ServiceLevel#1]
17325 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - calling onLoad()
17345 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - flushing session
17345 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - Flushing entities and processing referenced collections
17345 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - Processing unreferenced collections
17345 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - Scheduling collection removes/(re)creates/updates
17345 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
17345 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
17355 [Spool Thread #0] DEBUG net.sf.hibernate.impl.Printer - listing entities:
17355 [Spool Thread #0] DEBUG net.sf.hibernate.impl.Printer - com.myadbox.bo.ServiceLevel{Price=0.62000, Description=A 30-day AdBox which allows 120
minutes of incoming toll-free calls, a daily notification with a summary of new messages, 10 MB of message storage, along with value-added services",
TermLengthDays=30, Name=Basic Service, MaxStorageSpace=10240, Id=1, MaxMinutes=120}
17355 [Spool Thread #0] DEBUG net.sf.hibernate.impl.Printer - com.myadbox.bo.MessageBox{Purpose=null, Status=A, RoutingNumber=null, SalesAgent=null,
PaymentPin=9832, MaxStorageSpace=10240, NotificationPhone=null, FormPrice=null, CreatedDate=2004-09-14 20:24:12, Greeting=null, BoxNumber=1, AccountNu
mber=null, Name=, MaxMinutes=120, MessageBoxGroup=null, ForwardingPhone=null, StartDate=14 September 2004, NotificationEmail=null, NotificationType=nu
ll, WebPageContents=null, ServiceLevel=ServiceLevel#1, LastMessageCreatedDate=2004-09-14 20:26:56, ExpirationDate=14 October 2004, Price=null, AcceptP
ayments=false, Reseller=null, BankName=null, Id=1}
17355 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - Dont need to execute flush
17355 [Spool Thread #0] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
17355 [Spool Thread #0] DEBUG net.sf.hibernate.SQL - select this.message_box_owner_id as user_id9_, this.message_box_id as message_2_16_9_, this.mess
age_box_group_id as message_3_16_9_, this_1_.passwd as passwd14_9_, this_1_.status as status14_9_, this_1_.last_name as last_name14_9_, this_1_.email_
address as email_ad5_14_9_, this_1_.phone_number as phone_nu6_14_9_, this_1_.first_name as first_name14_9_, messagebox1_.message_box_id as message_1_0
_, messagebox1_.notification_phone as notifica2_0_, messagebox1_.payment_pin as payment_3_0_, messagebox1_.web_page_contents as web_page4_0_, messageb
ox1_.bank_name as bank_name0_, messagebox1_.routing_nbr as routing_6_0_, messagebox1_.forwarding_phone as forwardi7_0_, messagebox1_.price as price0_,
messagebox1_.notification_email as notifica9_0_, messagebox1_.name as name0_, messagebox1_.notification_type as notific11_0_, messagebox1_.form_price
as form_price0_, messagebox1_.status as status0_, messagebox1_.account_nbr as account14_0_, messagebox1_.max_minutes as max_min15_0_, messagebox1_.ma
x_storage_space as max_sto16_0_, messagebox1_.box_number as box_number0_, messagebox1_.created_date as created18_0_, messagebox1_.start_date as start_
date0_, messagebox1_.expiration_date as expirat20_0_, messagebox1_.accept_payments as accept_21_0_, messagebox1_.last_message_created_date as last_me2
2_0_, messagebox1_.service_level_id as service23_0_, messagebox1_.message_box_group_id as message24_0_, messagebox1_.greeting_id as greetin25_0_, mess
agebox1_.purpose_id as purpose_id0_, messagebox1_.reseller_id as reselle27_0_, messagebox1_.sales_agent_id as sales_a28_0_, servicelev2_.service_level
_id as service_1_1_, servicelev2_.name as name1_, servicelev2_.max_storage_space as max_stor3_1_, servicelev2_.max_minutes as max_minu4_1_, servicelev
2_.price as price1_, servicelev2_.term_length_days as term_len6_1_, servicelev2_.description as descript7_1_, messagebox3_.message_box_group_id as mes
sage_1_2_, voicemessa4_.voice_message_id as message_id3_, voicemessa4_.message_url as message_2_3_3_, voicemessa4_.message_length as message_3_3_3_, v
oicemessa4_.from_phone_number as from_pho4_3_3_, voicemessa4__1_.status as status2_3_, voicemessa4__1_.created_date as created_3_2_3_, voicemessa4__1_
.storage_size as storage_4_2_3_, voicemessa4__1_.message_box_id as message_5_2_3_, messagebox5_.message_box_purpose_id as message_1_4_, messagebox5_.n
ame as name4_, messagebox5_.title as title4_, messagebox5_.form_name as form_name4_, messagebox5_.form_name_plural as form_nam5_4_, messagebox5_.form_
title as form_title4_, messagebox5_.form_title_plural as form_tit7_4_, messagebox5_.form_template as form_tem8_4_, reseller6_.reseller_id as reseller1
_5_, reseller6_.status as status5_, reseller6_.name as name5_, reseller6_.client_contact_id as client_c4_5_, reseller6_.address_line_1 as address_5_5_
, reseller6_.address_line_2 as address_6_5_, reseller6_.address_city as address_7_5_, reseller6_.address_state as address_8_5_, reseller6_.address_zip
as address_9_5_, clientcont7_.client_contact_id as user_id6_, clientcont7__1_.passwd as passwd14_6_, clientcont7__1_.status as status14_6_, clientcon
t7__1_.last_name as last_name14_6_, clientcont7__1_.email_address as email_ad5_14_6_, clientcont7__1_.phone_number as phone_nu6_14_6_, clientcont7__1_
.first_name as first_name14_6_, salesagent8_.sales_agent_id as user_id7_, salesagent8__1_.passwd as passwd14_7_, salesagent8__1_.status as status14_7_
, salesagent8__1_.last_name as last_name14_7_, salesagent8__1_.email_address as email_ad5_14_7_, salesagent8__1_.phone_number as phone_nu6_14_7_, sale
sagent8__1_.first_name as first_name14_7_, messagebox9_.message_box_group_id as message_1_8_ from message_box_owner this inner join df_user this_1_ on
this.message_box_owner_id=this_1_.user_id left outer join message_box messagebox1_ on this.message_box_id=messagebox1_.message_box_id left outer join
service_level servicelev2_ on messagebox1_.service_level_id=servicelev2_.service_level_id left outer join message_box_group messagebox3_ on messagebo
x1_.message_box_group_id=messagebox3_.message_box_group_id left outer join voice_message voicemessa4_ on messagebox1_.greeting_id=voicemessa4_.voice_m
essage_id left outer join message voicemessa4__1_ on voicemessa4_.voice_message_id=voicemessa4__1_.message_id left outer join message_box_purpose mess
agebox5_ on messagebox1_.purpose_id=messagebox5_.message_box_purpose_id left outer join reseller reseller6_ on messagebox1_.reseller_id=reseller6_.res
eller_id left outer join client_contact clientcont7_ on reseller6_.client_contact_id=clientcont7_.client_contact_id left outer join df_user clientcont
7__1_ on clientcont7_.client_contact_id=clientcont7__1_.user_id left outer join sales_agent salesagent8_ on messagebox1_.sales_agent_id=salesagent8_.s
ales_agent_id left outer join df_user salesagent8__1_ on salesagent8_.sales_agent_id=salesagent8__1_.user_id left outer join message_box_group message
box9_ on this.message_box_group_id=messagebox9_.message_box_group_id where this.message_box_id=?
17365 [Spool Thread #0] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
17365 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - binding '1' to parameter: 1
17375 [Spool Thread #0] DEBUG net.sf.hibernate.loader.Loader - processing result set
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning '1' as column: message_1_0_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning '1' as column: service_1_1_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: message_1_2_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: message_id3_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: message_1_4_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: reseller1_5_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: user_id6_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: user_id7_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: message_1_8_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning '1' as column: user_id9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.loader.Loader - result row: 1, 1, null, null, null, null, null, null, null, 1
17375 [Spool Thread #0] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 1
17375 [Spool Thread #0] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: com.myadbox.bo.MessageBoxOwner#1
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning '1' as column: message_2_16_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.LongType - returning null as column: message_3_16_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.StringType - returning 'GvhcgkNeNX0=' as column: passwd14_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.StringType - returning 'Hudson' as column: last_name14_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.StringType - returning 'j@j.com' as column: email_ad5_14_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.StringType - returning '5345235234' as column: phone_nu6_14_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.type.StringType - returning 'Joe' as column: first_name14_9_
17375 [Spool Thread #0] DEBUG net.sf.hibernate.loader.Loader - done processing result set (1 rows)
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
17375 [Spool Thread #0] DEBUG net.sf.hibernate.loader.Loader - total objects hydrated: 1
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - resolving associations for [com.myadbox.bo.MessageBoxOwner#1]
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - loading [com.myadbox.bo.MessageBox#1]
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [com.myadbox.bo.MessageBox#1]
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [com.myadbox.bo.MessageBox#1]
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [com.myadbox.bo.MessageBoxOwner#1]
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - closing session
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - disconnecting session
17375 [Spool Thread #0] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - done materializing entity [com.myadbox.bo.MessageBox#1]
17375 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - initializing non-lazy collections
false
17385 [Spool Thread #0] DEBUG net.sf.hibernate.transaction.JDBCTransaction - begin
17385 [Spool Thread #0] DEBUG net.sf.hibernate.impl.SessionImpl - closing session
net.sf.hibernate.HibernateException: Session is closed
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3292)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2231)
at com.myadbox.mail.parser.MailRouter.service(MailRouter.java:58)
at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:407)
at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:451)
at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:360)
at java.lang.Thread.run(Thread.java:534)
exception! javax.mail.MessagingException: Session is closed



Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 15, 2004 8:25 pm 
Beginner
Beginner

Joined: Mon May 24, 2004 7:39 pm
Posts: 37
Location: Charlotte
Sorry, stupid mistake. I know what my problem was... I'm just dumb.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.