Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: No Testcase No Testcase
Assignee: Unassigned
Reporter: Sunil
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

Not able to access JPQL methods like Max in karaf 2.2.6 OSGI environment

Created: 15/Aug/12 10:44 PM   Updated: 12/Sep/12 04:56 PM   Resolved: 30/Aug/12 04:54 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.1.1

File Attachments: 1. Zip Archive sample-consumer-basic - (9 kB)

Environment: Windows xp, Java 1.6, Apache Karaf 2.2.6, OSGI

Forum Thread URL:,7219
Datastore: MySQL
Severity: Production

 Description  « Hide
I am getting error during runtime when i try to use the Max function in a query given below (EVERY THING IS WORKING AS EXPECTED IF I AM NOT USING ANY METHOD).

Query q = em.createQuery("SELECT max(s.studentID) FROM StudentJpa s");
Long value = (Long)q.getSingleResult();
System.out.println("MAX VALUE IS ***************** " + value);

The error is given below.

Caused by: org.datanucleus.exceptions.NucleusUserException: Expected SQLMethod class "" was not found!
        at org.datanucleus.api.jpa.JPAQuery.getSingleResult(

JDOClassLoaderResolver is not able to load this class using any class loader. is exporting all the methods in that particular package but no bundle is importing it.
I believe datanucleus is missing something here.

Sort Order: Ascending order - Click to sort in descending order
Sunil added a comment - 15/Aug/12 10:45 PM
i am using datanucleus core 3.0.10
all rest bundles 3.0.9
api.jdo 3.0.7

Andy Jefferson added a comment - 20/Aug/12 07:53 AM
What this issue allegedly had to do with "NUCJPAQUERY" (the code that generates the JPA MetaModel classes) is beyond me. It also claims in the description that you're using JDO (api.jdo), yet then says JPA.

Sunil added a comment - 20/Aug/12 08:50 AM

see the flow of the call that is failing.

I have given my environment what bundles i am using. Check the 2nd line below (it says other datanucleus bundles are having version 3.0.9, which includes api.jpa also):
i am using datanucleus core 3.0.10
all rest bundles 3.0.9
api.jdo 3.0.7

Andy Jefferson added a comment - 26/Aug/12 01:11 PM - edited
Suggest you use 3.1.1 (now released), since you may have something related to NUCRDBMS-606 (no way of reproduction of problem provided) and report back. I don't plan on further 3.0.x releases; the only way I'll be backdating changes to 3.0 is if a commercial client provides a good justification for sticking to 3.0 and want to use an incident on it.

Andy Jefferson added a comment - 30/Aug/12 03:22 PM
1). I would prefer *no* other deps, presence of deps implies the chance of something else causing the problem. So just some entity, the JPA main and DataNucleus, so omit Spring (particularly as your DasJpa doesn't use it!). You have "datanucleus-api-jdo" yet are using JPA, so remove it. You have mongodb, why since using RDBMS? remove it.

What is "datanucleus.option.mapping"? Doesn't exist.

2). Post the exception you say you get with current codebase; it certainly is not what you post in the issue (since 3.1 is different code). All method instances are generated by OSGi's class loader, so since it works for everyone else who use OSGi then you must be doing "something different".

3). Please provide some step-by-step guide of what (command) you run "in Karaf", since I am not familiar with it. I would expect some sort of load bundle(s), in some order, followed by some invocation ... so what is the karaf-specific commands (or if done via a Maven plugin, what is the "mvn" plugin and method?)

Andy Jefferson added a comment - 30/Aug/12 03:49 PM
Also, could you try invoking a method that is on a type .. e.g String.length(), since the only thing about "MAX" is that it is effectively a static method and the "class" is not specified in OSGi plugin.xml so when it looks up the method evaluator it will try to match on class of "null" for max. If such as String works then that implies where the problem is

Sunil added a comment - 30/Aug/12 03:53 PM
Now more clarity, i think you are confused by datanucleus-api-jdo.

i am using datanuclues-api-jpa only.

datanucleus-api-jdo is also present in the karaf, if you want you can remove it. I told you this because you should know what things are present in my environment.

Sample osgi consumer is attached - more clear one.
You will get error with max function usage in latest datanucleus libraries also.

Can you please look into it.
Please run it in apache karaf 2.2.7 with all the dependecy provided in karaf deploy folder.)

Sunil added a comment - 30/Aug/12 03:56 PM
fill your database properties in the sample code that i sent. database is mysql 5.5.27.

Sunil added a comment - 30/Aug/12 04:00 PM
what i found in my analysis, datanucleus is able to find that max function call in JPQL corresponds to a MaxFunction call but JDOClassLoaderResolver is not able to load this class with any of the class loaders.

Andy Jefferson added a comment - 30/Aug/12 04:05 PM
Please refer to my previous 2 posts ... I asked for
1. stack trace in 3.1.1
2. step by step instructions for Karaf ; put *what* in karaf "deploy" directory ? jars? which jars? As said I prefer not to have Spring, so that means what ? I create a jar of your app first presumably? and include that? and then which others?

JDOClassLoaderResolver does not do the loading of that class ... OSGi does ... in 3.1.1. In 3.0 it is different, using JDOClassLoaderResolver ... hence why I asked for stack trace

Sunil added a comment - 30/Aug/12 04:22 PM
Looks like some positive is happening, but i am verifying it again.

Sunil added a comment - 30/Aug/12 04:45 PM
It is working with 3.1.1 jars.

Did you solve this issue in 3.1.1 after some issue reporting or how, just curious to know.

Andy Jefferson added a comment - 30/Aug/12 04:54 PM
Good that it works now. Marking as dup of NUCRDBMS-606 since that is presumably the issue that fixes it in 3.1.1.

NUCRDBMS-606 was not done due to a reported problem, just that I was checking the majority of usages of PluginManager "ConfigurationElement" and checked that they were creating instances of classes always via the PluginManager and found the RDBMS SQL method and operation extensions in v3.0 were using ClassLoaderResolver (which doesn't work under OSGi). These were changed to use PluginManager instead.