[英]NoClassDefFound in proxy class using InvocationHandler and invoke
We're using JPA (eclipselink 2.5.2 and also tried 2.6.2) and are facing an odd issue: 我们正在使用JPA(eclipselink 2.5.2,也尝试了2.6.2),并且面临一个奇怪的问题:
We have some classes, which are accessed via a proxy of itself (as described in this post (the marked solution): Call a method any time other methods are called ) 我们有一些类,可以通过自身的代理来访问(如本文中所述(标记为解决方案)所述:在调用其他方法时调用一个方法 )
Now, we're facing the following issue: When calling getResultList() on our named queries, we now get this exception: 现在,我们面临以下问题:在我们的命名查询上调用getResultList()时,现在出现此异常:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class java.lang.reflect.Proxy$ProxyAccessHelper
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:746)
at com.sap.core.persistence.jdbc.trace.ResultSetProxy.createProxy(ResultSetProxy.java:27)
at com.sap.core.persistence.jdbc.trace.TraceablePreparedStatement.executeQuery(TraceablePreparedStatement.java:78)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1007)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:642)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1991)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:250)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2738)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2691)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:495)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1168)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
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:1793)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1775)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1740)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)
I debugged into this for a long time to no avail. 我调试了很长时间没有任何结果。 The jpa using method is in the same context as the proxy is defined, so basically the actual proxy class should exist.
jpa using方法与定义代理的上下文相同,因此基本上应该存在实际的代理类。
Edit: I just noticed that the problem is not JPA related. 编辑:我只是注意到问题与JPA不相关。 I get the same issue, when running method.getAnnotations() inside the proxy.
当在代理内运行method.getAnnotations()时,出现相同的问题。 I get the same exception as above deep within a java stacktrack (parseAnnotations and stuff, to bad I didn't edit this afternoon, when I had access to the stacktrace).
我在java stacktrack的深处遇到了与上面相同的异常(parseAnnotations和其他东西,很糟糕,今天下午我可以访问stacktrace时没有编辑)。 This implies that it's some class loader issue and I just can't fathom it.
这意味着这是一个类加载器问题,我只是无法理解。
If anyone has a clue, please enlighten me. 如果有人有线索,请赐教。
Thanks and regards, Kay 谢谢和问候,凯
Found the problem and it is entirely unrelated to classloaders, visibility and stuff: 发现了问题,它与类加载器,可见性和东西完全无关:
For some reasons I still haven't figured out the webapps folder in my tomcat didn't get cleaned up when redeploying my packages and there were old files and bundles etc. in there, which cause the exception seen above. 由于某些原因,我仍然没有发现重新部署软件包时,tomcat中的webapps文件夹没有得到清理,并且里面有旧文件和捆绑包等,这导致了上面看到的异常。
Cleaned it manually, deployed it all to tomcat -> works like a charm... 手动清理它,将其全部部署到tomcat->就像一个魅力...
I hate it, when such arbitrary issues cause errors. 当这样的任意问题导致错误时,我讨厌它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.