Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ExpressionBuilder is null when there are concurrent request(ExpressionBuilder is (sometimes) null when there are concurrent request)
ExpressionBuilder is null when there are concurrent request [message #1129366] Tue, 08 October 2013 15:02 Go to next message
Amod M is currently offline Amod M
Messages: 11
Registered: July 2009
Junior Member
Hi,

We get lots of NullPointerException in and()/or() method of class org.eclipse.persistence.expressions.Expression espcially when there are large number of concurrent request. We are not reusing or caching expressions, expression builders. We get these errors intermittently.

1. Caused by: java.lang.NullPointerException
at org.eclipse.persistence.expressions.Expression.and(Expression.java:207)

2. Caused by: java.lang.NullPointerException
at org.eclipse.persistence.expressions.Expression.or(Expression.java:3193)

3. Exception data: java.lang.NullPointerException at org.eclipse.persistence.internal.descriptors.ObjectBuilder.extractPrimaryKeyFromExpression(ObjectBuilder.java:1725)

4. Caused by: java.lang.NullPointerException at org.eclipse.persistence.internal.expressions.QueryKeyExpression.rebuildOn(QueryKeyExpression.java:636) at org.eclipse.persistence.internal.expressions.CompoundExpression.rebuildOn(CompoundExpression.java:298)
at org.eclipse.persistence.expressions.Expression.and(Expression.java:208)


Expressions that we create are simple (not even parralel expression)
e.g. ExpressionBuilder builder = new ExpressionBuilder();
Expression exp = builder.get( "field1").equal( xyz).and(
builder.get( "field2" ).isNull()).and(
builder.get( "field3").equal(abc))


If we look inside and(Expression theExpression), or(Expression theExpression) method of Expression class, it is trying to ensure that same expression builder is getting used >>
if ((theExpression.getBuilder() != base) && ((base == this) || (theExpression.getBuilder().getQueryClass() == null))) {
expressionToUse = theExpression.rebuildOn(base);
}

Somehow theExpression.getBuilder() is coming as null.

OR

extractPrimaryKeyFromExpression() method of ObjectBuilder: expression.getBuilder() is coming as null.

Does any one has any idea about these issues?

For some other issue, I have seen suggestions for turning query cache off i.e. descriptor.getQueryManager().setExpressionQueryCacheMaxSize(0);
There is Expression query cache in DescriptorQueryManager. Is this a known issue?

Appreciate any suggestions...
Thanks & Regards.
Re: ExpressionBuilder is null when there are concurrent request [message #1129410 is a reply to message #1129366] Tue, 08 October 2013 15:55 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
Can you define what you are using concurrently? I don't see how an NPE could occur within Expression.or and Expression.and calls without some sort of expression reuse happening in the code, as the application should have obtained these objects from a local ExpressionBuilder instance. Something must be modifying the expression concurrently somehow. Can you show the code that is using the and/or calls?

Best Regards,
Chris
Re: ExpressionBuilder is null when there are concurrent request [message #1129960 is a reply to message #1129410] Wed, 09 October 2013 05:25 Go to previous messageGo to next message
Amod M is currently offline Amod M
Messages: 11
Registered: July 2009
Junior Member
Hi Chris,
Thanks for your reply. We are not reusing any Expression/ExpressionBuilder objects. These are all local variables. i.e. We are creating ExpressionBuilder locally in our DAO methods. e.g.
public void xxx(){
ExpressionBuilder builder = new ExpressionBuilder();
Expression exp = builder.get( "field1").equal( xyz).and(
builder.get( "field2" ).isNull()).and(
builder.get( "field3").equal(abc))
}

These NPE are only coming when there are large number of concurrent request.

Thanks & Regards,
Amod
Re: ExpressionBuilder is null when there are concurrent request [message #1130355 is a reply to message #1129960] Wed, 09 October 2013 13:24 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
What EclipseLink version are you using, and what environment (JVM) are you running in? Can you verify the code the NPE in or/and is coming from? If the expressionbuilder is not being reused, the only thing I can think of is a JVM issue, such that a multicore system hasn't fully initialized the expression passed into the AND call such that it is not null, but not initialized. That, or there is a similar problem with the static operator lookup method, but that seems less likely as this should just return a reference from a map.
Re: ExpressionBuilder is null when there are concurrent request [message #1130452 is a reply to message #1130355] Wed, 09 October 2013 15:16 Go to previous messageGo to next message
Amod M is currently offline Amod M
Messages: 11
Registered: July 2009
Junior Member
NPE is basically coming from 2 places:
1. Expression class, method: and(Expression theExpression) //and also or() method of class Expression. theExpression.getBuilder() is coming null

if ((theExpression.getBuilder() != base) && ((base == this) || (theExpression.getBuilder().getQueryClass() == null))) {
expressionToUse = theExpression.rebuildOn(base);
}
Normally, theExpression.getBuilder() == base is true, so above code path shouldn't get executed. But under heavy load, it seems that theExpression.getBuilder() is coming null && hence it goes for rebuild on base object.

2. QueryKeyExpression class, method: public Expression rebuildOn(Expression newBase) //newLocalBase is coming null
Expression newLocalBase = getBaseExpression().rebuildOn(newBase);
QueryKeyExpression result = null;
if (shouldUseOuterJoin) {
result = (QueryKeyExpression)newLocalBase.getAllowingNull(getName());
} else {
result = (QueryKeyExpression)newLocalBase.get(getName());
}

We are using EclipseLink 1.0.2 on Java 1.6. Though we plan to upgrade to latest version of Eclipselink, we need to fix this in current version.

Thanks & Regards,
Amod
Re: ExpressionBuilder is null when there are concurrent request [message #1148775 is a reply to message #1129366] Mon, 21 October 2013 18:42 Go to previous messageGo to next message
Radhakrishnan Jankiraman is currently offline Radhakrishnan Jankiraman
Messages: 1
Registered: October 2013
Junior Member
I am a colleague of Amod. We work as part of the same team Just wanted to share an update. The issue goes away if we get rid of the 'builder' field in the 'BaseExpression' class (I.E. get rid of the 'cache' ). We have verified this in our performance tests where we could consistently reproduce the issue and now after this change, it's not reproducible anymore. So your hunch about this being a potential JVM issue seems to be right. We are planning to run further tests on a different version of the JVM that our product was supported on in an earlier release, when the same code and same tests didn't report this issue. These tests were run on IBM J9 VM that ships with WebSphere Application Server 8.5.5. Here is the VM details :-

java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460_26sr6ifix-20130705(SR6+IV44889+IX90121))
IBM J9 VM (build 2.6, JRE 1.6.0 Linux amd64-64 Compressed References 20130702_154829 (JIT enabled, AOT enabled)
J9VM - R26_Java626_SR6_20130702_1557_B154829
JIT - r11.b04_20130528_38954ifx2
GC - R26_Java626_SR6_20130702_1557_B154829_CMPRSS
J9CL - 20130702_154829)
JCL - 20130618_01




Regards,
Radhakrishnan
Re: ExpressionBuilder is null when there are concurrent request [message #1219557 is a reply to message #1148775] Wed, 04 December 2013 15:51 Go to previous message
Reda Kolli is currently offline Reda Kolli
Messages: 1
Registered: December 2013
Junior Member
Radhakrishnan, Amod, Chris,

I am experiencing the same issue on Websphere 8.5.5.0 and we have noticed that the issue still happens with 8.5.5.1 but less frequently. I was wondering if any of you had any information on other solutions at the WebSphere or IBM JVM level (patch, upgrade, etc...).

I would also be interested in any solution/workaround on how to write the build the expression to go around this issue (Radhakrishnan mentioned a workaround on the BaseExpression, but that seem to involve a code change to the EclipseLink class).

Thanks in advance for any info,
Sincerely,
Reda.
Previous Topic:InvalidQuery key [...] exception with CriteriaQuery
Next Topic:Doing an Oracle db query with a PL/SQL Function in where clause
Goto Forum:
  


Current Time: Sun Sep 21 00:16:48 GMT 2014

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

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