-->
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.  [ 6 posts ] 
Author Message
 Post subject: JSP: Internal Server Error
PostPosted: Fri Mar 18, 2005 1:38 pm 
Newbie

Joined: Tue Mar 08, 2005 6:53 pm
Posts: 8
Hibernate version: 2

Code between sessionFactory.openSession() and session.close():
Code:
List records = session.find(
                "from HibernateConsumptionRecord as record where record.userId = ?"
                + " and record.consumptionDate >= ? and record.consumptionDate <= ?",
                new Object[] { userId, startDate,  endDate},
                new Type[] { Hibernate.STRING, Hibernate.DATE, Hibernate.DATE }
            );


Full stack trace of any exception that occurs:
There is no exception on the server. Everything runs fine. It actually displays messages such as:
Quote:
(SessionImpl.java:initializeEntity:2247) - done materializing entity

and
Quote:
(SessionImpl.java:afterTransactionCompletion:596) - transaction completion


With no exception. The only error message that I get is on my JSP page that runs my methods. The message that I get is:

Quote:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.


Name and version of the database you are using: SQL Server 2000

The thing is that sometimes I execute the JSP and it works fine and sometimes it doesn't.

I truly appreciate your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 2:26 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Quote:
The server encountered an unexpected condition which prevented it from fulfilling the request.

Well that's not very helpful for us. Look in the tomcat logs for a detailed error message - that may help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 2:37 pm 
Newbie

Joined: Tue Mar 08, 2005 6:53 pm
Posts: 8
I'm using Weblogic Server 8.1 and I looked in the log and I only get the normal DEBUG messages from Hibernate. I can post them to see if they help but I don't think it's likely. I'm also going to post my classes and methods so you can take a look and see:

Code:
public class TVMHibernateUtil {

    private static Logger logger = Logger.getLogger("TVMHibernateUtil");

    // Used for log messages (DEBUGGING)
    private String CLASS_NAME = "tellarian.valuation.valuator.session.TVMHibernateUtil";

    // For Connection
    private static String file = "/hibernate.cfg.xml";
   
   
    //Get a SessionFactory
    private static final SessionFactory sessionFactory;

    static {
        try {
            // Create the SessionFactory
            URL url = TVMHibernateUtil.class.getResource(file);
            sessionFactory = new Configuration().configure(url).buildSessionFactory();
        } catch (Throwable ex) {
            logger.error("Initial SessionFactory creation failed.", ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
   
    /**
     * <p>
     * Sets the associated session context. The container calls this method after the instance creation.
     * </p>
     */
    public static Session openSession() throws HibernateException{
        try {
            Session session;
           
             session = sessionFactory.openSession();
                       
            return session;
        } catch (HibernateException e) {
            logger.debug("Error while opening hibernate session: " + e);
            throw e;
        }
    }
   
   
    public static void closeSession(Session session) throws HibernateException{
        try {
           if(!session.isOpen()){
               session.close();
           }       
        } catch (HibernateException e) {
            logger.debug("Error while closing hibernate session: " + e);
            throw e;
        }
    }
}


Code:
public class TVMHibernateManager {

    private static Logger logger = Logger.getLogger("TVMHibernateManager");
   
    private static String CLASS_NAME = "TVMHibernateManager";
   
    /**
     * Persist a record to the database
     */   
    public void saveRecord(HibernateConsumptionRecord record){
        try {
            Session session = TVMHibernateUtil.openSession();
           
            session.save(record);
            session.flush();
           
            TVMHibernateUtil.closeSession(session);
        } catch (Exception e){
            e.printStackTrace();   
        }
    }
   
    /**
     * Find all records that correspond to this user Id
     */
    public List getRecordsByUserId(String userId) throws TellarianException{
        String methodName = "getRecordsByUserId";
       
        try {
            Session session = TVMHibernateUtil.openSession();
           
            List records = session.find(
                "from HibernateConsumptionRecord as record where record.userId = ?",
                userId,
                Hibernate.STRING
            );                                   
           
            TVMHibernateUtil.closeSession(session);
           
            return records;
        } catch (HibernateException e){
            logger.error(e);
            throw new TellarianException(CLASS_NAME, methodName,
                    "Could not find hibernate records by User Id: " + userId);
        }
    }
   
    /**
     * Find all records that correspond to this user Id and were made
     * between the given dates.
     */
    public List getRecordsByUserIdAndDates(String userId,
            Date startDate, Date endDate) throws TellarianException{
        String methodName = "getRecordsByUserIdAndDates";
       
        try {
            Session session = TVMHibernateUtil.openSession();
           
            List records = session.find(
                "from HibernateConsumptionRecord as record where record.userId = ?"
                + " and record.consumptionDate >= ? and record.consumptionDate <= ?",
                new Object[] { userId, startDate,  endDate},
                new Type[] { Hibernate.STRING, Hibernate.DATE, Hibernate.DATE }
            );                                   
           
            TVMHibernateUtil.closeSession(session);
           
            return records;
        } catch (HibernateException e){
            SimpleDateFormat dateFormat = new SimpleDateFormat();
           
            logger.error(e);
           
            throw new TellarianException(CLASS_NAME, methodName,
                    "Could not find hibernate records by User Id: " + userId
                    + " between dates: " + dateFormat.format(startDate) + " and "
                    + dateFormat.format(endDate));
        }
    }
   
    /**
     * Find all records that correspond to this cost center
     */
    public List getRecordsByCostCenter(String costCenterId) throws TellarianException{
        String methodName = "getRecordsByCostCenter";
       
        try {
            Session session = TVMHibernateUtil.openSession();
           
            List records = session.find(
                "from HibernateConsumptionRecord as record where record.costCenterId = ?",
                costCenterId,
                Hibernate.STRING
            );                                   
           
            TVMHibernateUtil.closeSession(session);
           
            return records;
        } catch (HibernateException e){
            logger.error(e);
            throw new TellarianException(CLASS_NAME, methodName,
                    "Could not find hibernate records by Cost Center: " + costCenterId);
        }
    }
   
    /**
     * Find all records that correspond to this cost center and were made
     * between the given dates.
     */
    public List getRecordsByCostCenterAndDates(String costCenterId,
            Date startDate, Date endDate) throws TellarianException {
        String methodName = "getRecordsByCostCenterAndDates";
        try {
            Session session = TVMHibernateUtil.openSession();
           
            List records = session.find(
                "from HibernateConsumptionRecord as record where record.costCenterId = ?"
                + " and record.consumptionDate >= ? and record.consumptionDate <= ?",
                new Object[] { costCenterId, startDate,  endDate},
                new Type[] { Hibernate.STRING, Hibernate.DATE, Hibernate.DATE }
            );                                   
           
            TVMHibernateUtil.closeSession(session);
           
            return records;
        } catch (HibernateException e){
            SimpleDateFormat dateFormat = new SimpleDateFormat();
           
            logger.error(e);
           
            throw new TellarianException(CLASS_NAME, methodName,
                    "Could not find hibernate records by Cost Center: " + costCenterId
                    + " between dates: " + dateFormat.format(startDate) + " and "
                    + dateFormat.format(endDate));
        }
    } 
}


Here is the log:
    DEBUG [13:04:57] (BatcherImpl.java:getPreparedStatement:253) - preparing statement
    DEBUG [13:04:57] (NullableType.java:nullSafeSet:46) - binding '262' to parameter: 1
    DEBUG [13:04:57] (NullableType.java:nullSafeSet:46) - binding '01 March 2005' to parameter: 2
    DEBUG [13:04:57] (NullableType.java:nullSafeSet:46) - binding '01 April 2005' to parameter: 3
    DEBUG [13:04:57] (Loader.java:doQuery:281) - processing result set
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '12' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 12
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 12
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#12
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 00:22:41' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '721' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '72.1' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '13' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 13
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 13
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#13
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 00:23:16' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '721' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '72.1' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (SessionImpl.java:finalize:3435) - running Session.finalize()
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '205' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 205
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 205
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#205
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:12:15' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80992311203' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '12' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.24' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '223' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 223
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 223
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#223
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:39:23' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '231' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 231
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 231
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#231
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:35:39' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '239' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 239
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 239
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#239
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:40:17' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '551' as column: id
    DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 551
    DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 551
    DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#551
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-18 10:12:32' as column: consumpt4_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596943031' as column: dialedNu5_
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
    DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
    DEBUG [13:04:57] (Loader.java:doQuery:298) - done processing result set (7 rows)
    DEBUG [13:04:57] (BatcherImpl.java:logClosePreparedStatement:211) - done closing: 0 open PreparedStatements, 0 open ResultSets
    DEBUG [13:04:57] (BatcherImpl.java:closePreparedStatement:275) - closing statement
    DEBUG [13:04:57] (Loader.java:initializeEntitiesAndCollections:318) - total objects hydrated: 7
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#12]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#12]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#13]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#13]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#205]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#205]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#223]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#223]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#231]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#231]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#239]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#239]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#551]
    DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#551]
    DEBUG [13:04:57] (SessionImpl.java:initializeNonLazyCollections:3161) - initializing non-lazy collections
    DEBUG [13:04:57] (SessionImpl.java:close:578) - closing session
    DEBUG [13:04:57] (SessionImpl.java:disconnect:3383) - disconnecting session
    DEBUG [13:04:57] (SessionImpl.java:afterTransactionCompletion:596) - transaction completion


Hope this helps. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 2:57 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Where is YOUR logger output going when an exception is caught and logged?

Code:
logger.error(e);


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 3:05 pm 
Newbie

Joined: Tue Mar 08, 2005 6:53 pm
Posts: 8
It's going to the same place where I got the hibernate log entries from.

Regarding the session, did you see anything funny in the code? or does it seem to be alright?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 3:38 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
No. The code looks ok.
You need to find out what is causing the exception that results in the internal server error. It may not be related to hibernate at all. It may not even be an exception in your code - at least it appears not to be as you would have some record of it.

You mentioned that you are using weblogic as the server. From my experience with websphere this (the internal server error page) is a page that is typically served when the http server (apache?) can't route the request to a jsp/servlet container for some reason.

A tricky one.


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