简体   繁体   English

使用InvocationHandler在代理类中调用NoClassDefFound并调用

[英]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.

相关问题 为什么InvocationHandler中的方法invoke()有一个参数Object proxy? - why does the method invoke() in InvocationHandler have an parameter Object proxy? 了解java.lang.reflect.InvocationHandler的invoke方法的“代理”参数 - Understanding “proxy” arguments of the invoke method of java.lang.reflect.InvocationHandler 对我的代理类中的每个方法执行InvocationHandler调用方法 - Execute InvocationHandler invoke method for each method at my proxied class 为什么jdk动态代理在调试每一步模式时调用InvocationHandler.invoke“toString”方法 - Why jdk dynamic proxy invoke InvocationHandler.invoke “toString” method when debug every step over mode 为什么我可以在InvocationHandler的invoke()方法中调用proxy.getClass()? - Why can I call proxy.getClass() inside InvocationHandler's invoke() method? 调用的java.lang.reflect.InvocationHandler的方法参数列表中的“代理”对象代表什么? - What does “proxy” object from invoke's method parameters list of java.lang.reflect.InvocationHandler represent? 代理实例如何将自身传递给InvocationHandler? - How the proxy instance pass itself to the InvocationHandler? 替换java.lang.reflect.Proxy中的InvocationHandler - Replace InvocationHandler in java.lang.reflect.Proxy 调试动态代理创建会改变调用处理程序状态 - Debugging dynamic proxy creation mutates invocationhandler state Application类的NoClassDefFound - NoClassDefFound from Application class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM