//運行時異常 在netbeans中調用以下代碼時發生運行時異常。在日食中工作正常。爲什麼這段代碼在netbeans中拋出一個ClassCastException而在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);
}
}
異常堆棧跟蹤是
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)
我無法來解決這個例外。因爲一切似乎都很好,相同的代碼在eclipse中運行良好,但生成運行時異常。
請檢查你的項目設置(如編譯器設置)和Jar參考的構建路徑...檢查你在Netbean和Eclipse項目中使用相同版本的JAR ... –
看起來像依賴jar問題請檢查所有依賴jar是否配置正確。 –
所有家屬都已正確配置。在依賴關係中,我可以看到依賴的罐子。我被卡住了。 – bilalhaider