ClassNotFoundException on create of TypedQuery [message #646634] |
Wed, 29 December 2010 08:04  |
Eclipse User |
|
|
|
Hello,
i hope someone can help me with the following problem. I am using EclipseLink in an RCP environment with the Target Platform set up accordingly. Creating an EntityManager works fine. (I've done some connection tests as well as persisting some simple data-objects.)
But, when I try to create a TypedQuery I get the following Exception:
java.lang.ClassNotFoundException: org.eclipse.persistence.internal.libraries.antlr.runtime.Parser
...
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:182)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:134)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:118)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1371)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1393)
I figured this to be some kind of "missing-plugin" problem, but I can't find out what is missing and why ... it's driving me crazy!
Working on Win7 64bit, Eclipse Helios 3.6.1, EclipseLink 2.1.1.v20100817-r8050
Any help is greatly appreciated.
Regards,
Christoph
|
|
|
Re: ClassNotFoundException on create of TypedQuery [message #646653 is a reply to message #646634] |
Wed, 29 December 2010 11:33   |
Eclipse User |
|
|
|
Christoph,
Hi, it looks like you are missing the antlr plugin project. You can inport the source or jar at the following location. Note: you could also reference the nightly eclipselink.jar which incorporates the antlr project as well.
See the missing class and it's ANTLR project:
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/tr unk/plugins/org.eclipse.persistence.antlr/src/org/eclipse/pe rsistence/internal/libraries/antlr/runtime/Parser.java
The point of the CNFE is during named query parsing. It is pretty hard to reproduce the ClassNotFoundException because there are so many references to antlr via the jpa or core project (I am running the same 64 bit environment as you - but this is a classpath issue).
In the following code JPQLParser extends antlr.runtime.Parser which requres the antlr project and antlr dependency.
EJBQueryImpl.java:211
public static DatabaseQuery buildEJBQLDatabaseQuery(String queryName, String jpql, Session session, Enum lockMode, Map<String, Object> hints, ClassLoader classLoader) {
JPQLParseTree parseTree = JPQLParser.buildParseTree(queryName, jpql);
antlr is a dependency on the core project (itself a dependency of the jpa project).
In the manifest
Require-Bundle: org.eclipse.persistence.antlr;bundle-version="2.2.0.qualifier ";resolution:=optional
Example:
Entity.....
@NamedQuery(
name="findAllHyperCubes",
query="SELECT OBJECT(h) FROM HyperCube h WHERE h.size > 0")
public class HyperCube<P> extends ComputeFabric implements Serializable
SE Client...
TypedQuery<HyperCube> aQuery = anEntityManager.createNamedQuery("findAllHyperCubes", HyperCube.class);
List<HyperCube> resultList = aQuery.getResultList();
runs as....
GridClient [Java Application]
org.eclipse.persistence.example.dataparallel.GridClient at localhost:63557
Thread [main] (Suspended)
EJBQueryImpl<X>.buildEJBQLDatabaseQuery(String, String, Session, Enum, Map<String,Object>, ClassLoader) line: 213
JPAQuery.processJPQLQuery(Session) line: 106
JPAQuery.prepare() line: 90
JPAQuery(DatabaseQuery).checkPrepare(AbstractSession, AbstractRecord, boolean) line: 577
JPAQuery(DatabaseQuery).checkPrepare(AbstractSession, AbstractRecord) line: 537
Giving us a parse tree....
parseTree JPQLParseTree (id=88)
classLoader null
context ParseTreeContext (id=91)
distinctState 0
fromNode FromNode (id=93)
groupByNode null
havingNode null
orderByNode null
queryNode SelectNode (id=97)
setNode null
unusedVariables null
validated false
whereNode WhereNode (id=100)
ServerSession(AbstractSession).processJPAQueries() line: 1985
ServerSession(DatabaseSessionImpl).initializeDescriptors() line: 409
ServerSession(DatabaseSessionImpl).postConnectDatasource() line: 667
ServerSession(DatabaseSessionImpl).login() line: 628
You can do one of 3 things.
1) add the org.eclipse.persistence.antlr project directly
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.persistence.antlr"/>
2) add a reference to the org.eclipse.persistence.core project (which won't compile without the antlr subproject)
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.persistence.core"/>
3) or add eclipselink.jar directly to your classpath
<classpathentry kind="lib" path="F:/view_w35e/eclipselink.jar" sourcepath="/org.eclipse.persistence.jpa"/>
thank you
/michael
http://www.eclipselink.org
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.95396 seconds