0

We're using JPA (eclipselink 2.5.2 and also tried 2.6.2) and are facing an odd issue:

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:

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.

Edit: I just noticed that the problem is not JPA related. I get the same issue, when running method.getAnnotations() inside the proxy. 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). 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

Community
  • 1
  • 1
Kay Jugel
  • 73
  • 11
  • The method calling into JPA has visibility, but does the JPA library (and the class loader that loaded it) have visibility to the proxy class? – Chris Apr 12 '16 at 14:21
  • How can I find this out? Everything that is used is basically in the same project and jpa is added via maven and everything is deployed as a war file on a tomcat, thus jpa should have visibility to the classes inside the this project. I noticed a similar issue later btw: There's also some checks on method annotations done in the proxy (the actual purpose of the proxy is to check those annotations). However, when Method.getAnnotations() is called, there's the same exception thrown as described above, which impies that it's not a JPA issue but some other class loading problem. – Kay Jugel Apr 12 '16 at 19:20

1 Answers1

0

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.

Cleaned it manually, deployed it all to tomcat -> works like a charm...

I hate it, when such arbitrary issues cause errors.

Kay Jugel
  • 73
  • 11