0

//Runtime Exception Runtime exception occurs when following code is called in netbeans. works fine in eclipse.

    public List<Ticket> findOpenTickets() {
            Session session = null;

            try {
                session = getSession();
                Criteria criteria = session.createCriteria(getReferenceClass());
                            criteria.add(Restrictions.eq(Ticket.PROP_CLOSED, Boolean.FALSE));
                List list = criteria.list();
                return list;
            } finally {
                closeSession(session);
            }
        }

exception stack trace is

java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Short
at org.apache.derby.client.net.NetStatementRequest.buildFDODTA(Unknown Source)
at org.apache.derby.client.net.NetStatementRequest.buildSQLDTAcommandData(Unknown Source)
at org.apache.derby.client.net.NetStatementRequest.writeOpenQuery(Unknown Source)
at org.apache.derby.client.net.NetPreparedStatement.writeOpenQuery_(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.writeOpenQuery(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeQueryX(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeQuery(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.model.dao.TicketDAO.findOpenTickets(TicketDAO.java:154)
at com.util.TicketActiveDateSetterTask.run(TicketActiveDateSetterTask.java:29)
at com.main.Application.initDatabase(Application.java:160)
at com.main.Application.start(Application.java:91)
at com.main.Main.main(Main.java:12)

I am unable to solve this exception. Because everything seems to be fine, same code is running fine in eclipse but producing runtime exception.

bilalhaider
  • 181
  • 2
  • 5
  • 15
  • Please Check Your Project Settings (like Compiler Setting )and Jar Reference in build path... Check wheteher your using same version of JAR in both Netbean and Eclipse Projects... – Karthikeyan Arumugam Sep 21 '12 at 07:25
  • Looks like dependency jar Issue please check whether all dependant jar's are properly configured. – Amit Deshpande Sep 21 '12 at 07:51
  • All dependents are properly configured. in dependencies i can see the dependent jars. I am stuck. – bilalhaider Sep 21 '12 at 08:17
  • Do you use the same database and do you select the same data when testing in Eclipse and in Netbeans? – Johanna Sep 21 '12 at 09:43
  • Yes i am using the same database with the eclipse and netbeans. – bilalhaider Sep 21 '12 at 10:00
  • In Derby DB SETTLED column is of type SMALLINT In Ticket.hbm.xml In Ticket.java public static String PROP_CLOSED = "closed"; Code that causes exception is I have the same code running fine in eclipse. what should i do in netbeans to achieve the desired result with lowest possible change. Its more than 10 hrs i am stuck at this. – bilalhaider Sep 21 '12 at 14:39

1 Answers1

1

check if your hibernate.dialect is proper or not?? It must be of your DB..

TaherT
  • 1,285
  • 2
  • 22
  • 41
  • it is properly set. code is running fine in eclipse but problem is in netbeans. – bilalhaider Sep 21 '12 at 13:42
  • In Derby DB SETTLED column is of type SMALLINT In Ticket.hbm.xml In Ticket.java `code`public static String PROP_CLOSED = "closed";`code` Code that causes exception is `code` criteria.add(Restrictions.eq(Ticket.PROP_CLOSED, false)); List list = criteria.list(); return list;`code` I have the same code running fine in eclipse. what should i do in netbeans to achieve the desired result with lowest possible change. Its more than 10 hrs i am stuck at this. – bilalhaider Sep 21 '12 at 15:40
  • 1
    change settled from smallint to boolean and try.. :) – TaherT Sep 22 '12 at 09:19