我在使用ThreadLocal的多线程环境中使用最新的eclipselink(2.5.2)来保证每个线程都使用自己的实体管理器,我在下面得到了例外。
通过互联网搜索我发现它发生在类似环境的2.3版本中。有没有人知道它的方法?怎么能克服这个?[EL Warning]: 2014-07-10 09:31:30.982--UnitOfWork(1713484147)--Thread(Thread[pool-2-thread-6,5,main])--Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: ReportQuery(name="query.rvTrans" referenceClass=RvTransaction sql="SELECT RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE, SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), MIN(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END), MAX(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END) FROM RV_TRANSACTION WHERE ((((((((AO_TYPE_3DPT = ?) AND (AONO_3DPT = ?)) AND (RV_PARTY_NO = ?)) AND (RV_PRODUCT IN (?, ?, ?, ?))) AND (RV_EMPLOYER_ID = ?)) AND (RV_IMPLEMENT_SW <> ?)) AND (RV_TRAN_STATUS <> ?)) AND (((RV_SOURCE_CD <> ?) AND (RV_VALUE_DATE <= ?)) OR ((RV_SOURCE_CD = ?) AND (RV_RATE_DATE <= ?)))) GROUP BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE ORDER BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE")
2014-07-10 09:31:31,001 [pool-2-thread-6] ERROR [RvTransactionManager] - PersistenceException: Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: ReportQuery(name="query.rvTrans" referenceClass=RvTransaction sql="SELECT RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE, SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), MIN(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END), MAX(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END) FROM RV_TRANSACTION WHERE ((((((((AO_TYPE_3DPT = ?) AND (AONO_3DPT = ?)) AND (RV_PARTY_NO = ?)) AND (RV_PRODUCT IN (?, ?, ?, ?))) AND (RV_EMPLOYER_ID = ?)) AND (RV_IMPLEMENT_SW <> ?)) AND (RV_TRAN_STATUS <> ?)) AND (((RV_SOURCE_CD <> ?) AND (RV_VALUE_DATE <= ?)) OR ((RV_SOURCE_CD = ?) AND (RV_RATE_DATE <= ?)))) GROUP BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE ORDER BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE")
javax.persistence.PersistenceException: Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: ReportQuery(name="query.rvTrans" referenceClass=RvTransaction sql="SELECT RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE, SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), MIN(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END), MAX(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END) FROM RV_TRANSACTION WHERE ((((((((AO_TYPE_3DPT = ?) AND (AONO_3DPT = ?)) AND (RV_PARTY_NO = ?)) AND (RV_PRODUCT IN (?, ?, ?, ?))) AND (RV_EMPLOYER_ID = ?)) AND (RV_IMPLEMENT_SW <> ?)) AND (RV_TRAN_STATUS <> ?)) AND (((RV_SOURCE_CD <> ?) AND (RV_VALUE_DATE <= ?)) OR ((RV_SOURCE_CD = ?) AND (RV_RATE_DATE <= ?)))) GROUP BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE ORDER BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE")
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:480)
at com.sapiens.crjpa.managers.RvTransactionManager.getResultLists(RvTransactionManager.java:41)
at com.sapiens.crjpa.tasks.SinglePartyLogic.getPartyAccumulation(SinglePartyLogic.java:66)
at com.sapiens.crjpa.tasks.Worker.run(Worker.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: ReportQuery(name="query.rvTrans" referenceClass=RvTransaction sql="SELECT RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE, SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), SUM(CASE WHEN (RV_TAX_CODE = ?) THEN RV_UNIT_VALUE ELSE ? END), MIN(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END), MAX(CASE WHEN ((RV_TRANSACT_TYPE = ?) AND (RV_CONN_TRAN_NBR = ?)) THEN RV_VALUE_DATE ELSE ? END) FROM RV_TRANSACTION WHERE ((((((((AO_TYPE_3DPT = ?) AND (AONO_3DPT = ?)) AND (RV_PARTY_NO = ?)) AND (RV_PRODUCT IN (?, ?, ?, ?))) AND (RV_EMPLOYER_ID = ?)) AND (RV_IMPLEMENT_SW <> ?)) AND (RV_TRAN_STATUS <> ?)) AND (((RV_SOURCE_CD <> ?) AND (RV_VALUE_DATE <= ?)) OR ((RV_SOURCE_CD = ?) AND (RV_RATE_DATE <= ?)))) GROUP BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE ORDER BY RV_PARTY_NO, RV_PRODUCT, RV_FUND_CODE")
at org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1590)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:680)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:901)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)
... 8 more
Caused by: java.lang.NullPointerException
at java.io.Writer.write(Writer.java:157)
at org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.printString(ExpressionSQLPrinter.java:188)
at org.eclipse.persistence.expressions.ExpressionOperator.printCollection(ExpressionOperator.java:2197)
at org.eclipse.persistence.internal.expressions.ArgumentListFunctionExpression.printSQL(ArgumentListFunctionExpression.java:99)
at org.eclipse.persistence.expressions.ExpressionOperator.printCollection(ExpressionOperator.java:2194)
at org.eclipse.persistence.internal.expressions.FunctionExpression.printSQL(FunctionExpression.java:545)
at org.eclipse.persistence.internal.expressions.FunctionExpression.writeFields(FunctionExpression.java:717)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.writeFieldsFromExpression(SQLSelectStatement.java:2033)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.writeFieldsIn(SQLSelectStatement.java:2048)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.printSQL(SQLSelectStatement.java:1675)
at org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printSQLSelectStatement(DatabasePlatform.java:3178)
at org.eclipse.persistence.platform.database.DB2Platform.printSQLSelectStatement(DB2Platform.java:787)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.buildCall(SQLSelectStatement.java:782)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.buildCall(SQLSelectStatement.java:792)
at org.eclipse.persistence.descriptors.ClassDescriptor.buildCallFromStatement(ClassDescriptor.java:813)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.setCallFromStatement(StatementQueryMechanism.java:390)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareReportQuerySelectAllRows(ExpressionQueryMechanism.java:1696)
at org.eclipse.persistence.queries.ReportQuery.prepareSelectAllRows(ReportQuery.java:1203)
at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:744)
at org.eclipse.persistence.queries.ReportQuery.prepare(ReportQuery.java:1071)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)
... 20 more
答案 0 :(得分:1)
在这段代码中,看起来EclipseLink Bugzilla中没有与Writer使用中的NPE相关的已知问题。 请在https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink上创建一个新错误 把这些信息和一些简单的复制方案(如果可能的话还有测试用例)放在那里。我们来看看它。