Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ClassNotFoundException on create of TypedQuery(Missing class "org.eclipse.persistence.internal.libraries.antlr.runtime.Parser")
ClassNotFoundException on create of TypedQuery [message #646634] Wed, 29 December 2010 13:04 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
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 16:33 Go to previous messageGo to next message
Michael OBrien is currently offline Michael OBrienFriend
Messages: 34
Registered: July 2009
Member
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
Re: ClassNotFoundException on create of TypedQuery [message #646675 is a reply to message #646653] Wed, 29 December 2010 19:19 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hello Michael,

thanks for pointing me in the right direction. I got the problem sorted out. It is a bit strange though. I wrote a small projekt to reproduce the effect. The dependencies are:

org.elcipse.core.runtime
mysqlWrapper (mysql connection jar in a wrapper plugin)
javax.persistence
org.eclipse.persistence.jpa

The effect is described as follows:

A) The plugin org.eclipse.persistence.antlr is not added to the configuration (Eclipse Application) on "Add Required Plug-ins" when "Include optional dependencies ..." is not activated.

B) After adding the plugin manualy to the configuration it still doesn't work. The classloader will bring the ClasNotFoundException described above.

C) After fooling around a bit I noticed that after changing the order of the dependencies it will suddenly work.

There is probaby a better way to have Eclipse "reset" it's loading of target-plugins ... ??

If someone is interested I can provide my simple test project to reproduce the effect.

Regards,
Christoph

Re: ClassNotFoundException on create of TypedQuery [message #646681 is a reply to message #646634] Wed, 29 December 2010 20:17 Go to previous messageGo to next message
Michael OBrien is currently offline Michael OBrienFriend
Messages: 34
Registered: July 2009
Member
Christoph,
Sounds good, If you have the time you could enter a bug on the product under the foundation category and it will pass through the triage queue next week for prioritization. Attaching a zip of your reproduction project would be helpfull.

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseL ink

Your route to development is a typical use case that should be verified on our side. Currently the projects are set to work under both PDE and OSGI - I am not an expert on using Maven and rarely use the update menu in Eclipse - for our own libraries for either SE or EE deployments - so the fact you caught this is good.

thank you
/michael
Re: ClassNotFoundException on create of TypedQuery [message #646687 is a reply to message #646681] Thu, 30 December 2010 00:51 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=333320
Previous Topic:References to subclass implemented as FK to superclass
Next Topic:problems using metamodel generator in Eclipse
Goto Forum:
  


Current Time: Tue Mar 19 02:11:48 GMT 2024

Powered by FUDForum. Page generated in 0.02230 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top