I am getting below error while calling
dynamoDBMapper.scan(Person.class, new DynamoDBScanExpression())
java.lang.NullPointerException: null
at com.amazonaws.services.dynamodbv2.model.ScanRequest.setScanFilter(ScanRequest.java)
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.createScanRequestFromExpression(DynamoDBMapper.java:1692)
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.scan(DynamoDBMapper.java:1569)
at com.amazonaws.services.dynamodbv2.datamodeling.AbstractDynamoDBMapper.scan(AbstractDynamoDBMapper.java:236)
With the same dynamoDBMapper, dynamoDBMapper.save(person1) is working fine.
The NullPointerExecption is coming inside of ScanRequest.setScanFilter method of the AWS SDK.
Although, the method setScanFilter has only one line of code, the stacktrace is not showing the line-number where the exception occurred.
The method ScanRequest.setScanFilter looks like this.
public void setScanFilter(java.util.Map<String, Condition> scanFilter) {
this.scanFilter = scanFilter;
}
Not sure how this.scanFilter = scanFilter can cause a NullPointerException
Spring Boot - 2.2.6.RELEASE
DynamoDB SDK - 1.11.555
Java - Corretto-8.242.08.1
#ShrinivasShukla I also found the NPE when Contrast is wired up in Application. In my case Probably Contrast is disabling/blocking scanRequest.setScanFilter(scanExpression.getScanFilter() to work.
Related
Am calling a popup dialog, this throws an error.
This code previously worked, but i recently uploaded a new build and my new build now produces an error message on the 15/07/2019
public Command showPopupDialog(Component c). this is the method in the Dialog class am calling.
Getting the following error message
java.lang.NullPointerException
at com.codename1.ui.plaf.Border.paintBorderBackground(Border.java:1435)
[EDT] 0:0:0,19 - Exception: java.lang.NullPointerException - null
at com.codename1.ui.plaf.Border.paintBorderBackground(Border.java:1267)
at com.codename1.ui.Component.paintBackgroundImpl(Component.java:2661)
at com.codename1.ui.Component.paintComponentBackground(Component.java:2625)
at com.codename1.ui.Container.paintComponentBackground(Container.java:2546)
at com.codename1.ui.Component.internalPaintImpl(Component.java:2239)
at com.codename1.ui.Component.paintInternalImpl(Component.java:2228)
at com.codename1.ui.Component.paintInternal(Component.java:2203)
at com.codename1.ui.Container.paint(Container.java:1639)
at com.codename1.ui.Form.paint(Form.java:4180)
at com.codename1.ui.Component.internalPaintImpl(Component.java:2255)
at com.codename1.ui.Form.internalPaintImpl(Form.java:4190)
at com.codename1.ui.Component.paintInternalImpl(Component.java:2228)
at com.codename1.ui.Component.paintInternal(Component.java:2203)
at com.codename1.ui.Component.paintInternal(Component.java:2171)
[EDT] 0:0:0,66 - Exception: java.lang.NullPointerException - null
at com.codename1.ui.Component.paintComponent(Component.java:2468)
at com.codename1.ui.animations.CommonTransitions.paint(CommonTransitions.java:1139)
at com.codename1.ui.animations.CommonTransitions.initTransition(CommonTransitions.java:469)
at com.codename1.ui.Display.initTransition(Display.java:1576)
at com.codename1.ui.Display.setCurrent(Display.java:1535)
at com.codename1.ui.Form.showModal(Form.java:2303)
at com.codename1.ui.Dialog.showModal(Dialog.java:1138)
at com.codename1.ui.Dialog.show(Dialog.java:582)
at com.codename1.ui.Dialog.showPopupDialog(Dialog.java:1287)
at com.codename1.ui.Dialog.showPopupDialog(Dialog.java:1154)
Either you're passing a parameter that's null, or you are trying to call a method on an object that is null.
So the simplest way of finding out which is null, is doing this:
System.out.println("myObject = "+myObject);
for every object that you're using near the nullpointer exception until you find something that's null.
This is a regression due to the fix for this issue. We fixed it and it will be available in the next update.
I'm guessing you have a style for PopupDialog in your theme. I suggest removing it as a workaround.
That is the best way in which I can describe what's going on.
This is my line of code:
if (offer.getFamily().getProfileImage() == null)
And this is what the debugger is showing:
Both offer and family aren't null.
So instead of going inside the if like it should it tries to get the file path and of course it fails with a NullPointerException.
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
at java.io.UnixFileSystem.resolve(UnixFileSystem.java:95)
at java.io.UnixFileSystem.resolve(UnixFileSystem.java:130)
at java.io.File.getAbsolutePath(File.java:524)
at com.yournanny.utilities.ProfileImageUtilities.showProfileImage(ProfileImageUtilities.java:109)
Here is where I get the error:
public static void showProfileImage(User user, ImageView image) {
image.setImageBitmap(BitmapFactory.decodeFile(user.getProfileImage().getAbsolutePath()));
}
What is going on here?
Update
Looking at the comments I broke the chains and re-run it, neither offer or getFamily() return null, if I call other method over them I get the expected values.
But getProfileImage() is definitely returning null, the problem is that somehow it isn't null enough when I compare it in the if.
But on calling getProfileImage().getAbsolutePath() I get this:
Well apparently the problem was with the deserialization of the offer (and particularly of the family inside of it).
I was getting offer through a retrofit get call.
I added transient to the profileImage attribute and this fixed the problem:
private transient File profileImage;
Now this is what the debugger shows:
So I'm guessing gson (I'm using it to deserialize the retrofit responses) was creating a file without a assigning it a path and that's why it was and wasn't null.
But a proper explanation would be great.
The File was non-null but its name was null internally.
I'm developing an Android App using Google Map and clustering.
I'm getting a Null Pointer Exception when I try to remove an Item from the cluster manager.
E/UncaughtException: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.remove(java.lang.Object)' on a null object reference
at com.google.maps.android.quadtree.PointQuadTree.remove(PointQuadTree.java:176)
at com.google.maps.android.quadtree.PointQuadTree.remove(PointQuadTree.java:171)
at com.google.maps.android.quadtree.PointQuadTree.remove(PointQuadTree.java:153)
at com.google.maps.android.clustering.algo.NonHierarchicalDistanceBasedAlgorithm.removeItem(NonHierarchicalDistanceBasedAlgorithm.java:95)
at com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.removeItem(PreCachingAlgorithmDecorator.java:61)
at com.google.maps.android.clustering.ClusterManager.removeItem(ClusterManager.java:161)
at com.company.myApp.controllers.MapClusterManager.removeItem(MapClusterManager.java:72)
The code that is throwing the exception is the following:
if(clusterManager.getAlgorithm().getItems().contains(mapClusterItem)) {
clusterManager.removeItem(mapClusterItem); // <-- NPE here
clusterManager.cluster();
}
As you can see I'm actually checking the existence of the item before the deletion.
The clustering setup follows:
clusterManager = new ClusterManager<MapClusterItem>(context, googleMap);
algo = new NonHierarchicalDistanceBasedAlgorithm<MapClusterItem>();
clusterManager.setAlgorithm(algo);
The problem is that PointQuadTree.remove(double x, double y, T item) (Google Library) throws the Exception.
Does anyone know how to solve it?
The GridBasedAlgoritm doesn't fit my case. I want to use the
NonHierarchicalDistanceBasedAlgorithm
.
I'm using the cluster library from Google Maps Utils.
compile 'com.google.maps.android:android-maps-utils:0.4.+'
It's a bug in the library, and it's going to be delivered a fixed version soon as said here:
https://github.com/googlemaps/android-maps-utils/issues/348
I am using wikidata api to fetch a entity using its english title,
wdf = WikibaseDataFetcher.getWikidataDataFetcher();
eid = wdf.getEntityDocumentsByTitle("enwiki", entitle);
Earlier, with an older version of wikidata-api, I was able to run it smoothly.
After updating to version 5.0.0, I always get the following error,
Exception in thread "main" java.lang.NullPointerException
at org.wikidata.wdtk.wikibaseapi.ApiConnection.fillCookies(ApiConnection.java:544)
at org.wikidata.wdtk.wikibaseapi.ApiConnection.sendRequest(ApiConnection.java:346)
at org.wikidata.wdtk.wikibaseapi.WbGetEntitiesAction.wbGetEntities(WbGetEntitiesAction.java:187)
How to fix this?
I get the same problem.
I tried to use latest version from github and get the same exception.
I execute the sample from documentation i.e the simple call:
Map<String, EntityDocument> results = wbdf.getEntityDocuments("Q80", "P31");
Seems code doesn't check for existence of a given cookie.
I added the verification, recompiled and everything seems to work.
Go to ApiConnection.java:543
if (headerCookies != null)
for (String cookie : headerCookies) {
No warranty ! :-)
We are getting a mustache play error in production (amazon linux EC2 AMI) but not in development (MACs) and we have tried upgrading the jvm, using the jdk instead, and changing from a tomcat deploy model to match our development environments as much as possible but nothing is working. Please any help would be greatly appreciated. We have lots of shared code in java and javascript using mustache and it would be a big deal to rewrite everything if we had to ditch mustache on the java side.
20:48:52,403 ERROR ~
#6al2dd0po
Internal Server Error (500) for request GET /mystuff/people
Execution exception (In {module:mustache-0.2}/app/play/modules/mustache/MustacheTags.java around line 32)
NullPointerException occured : null
play.exceptions.JavaExecutionException
at play.templates.BaseTemplate.throwException(BaseTemplate.java:90)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:660)
at play.mvc.Controller.renderTemplate(Controller.java:640)
at play.mvc.Controller.render(Controller.java:695)
at controllers.MyStuff.people(MyStuff.java:183)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
at play.modules.mustache.MustacheTags._template(MustacheTags.java:32)
at play.modules.mustache.MustacheTags$_template.call(Unknown Source)
at /app/views/User/people.html.(line:22)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
... 13 more
Seems the issue is with the threadlocal. In Prod as per my logs, the session gets initialized with the main thread.
[2012-06-30 18:35:38,102] INFO 10097[**main**] - Mustache module initialized
However, MustacheTag tries to access with various thread like this during request.
[2012-06-30 17:48:44,669] INFO 66048[**play-thread-1**] - [{module:mustache-0.2}/app/play/modules/mustache/MustacheTags.java:46] _meta() :: MustachePlugin.session():null
So I changed the implementation of MustachePlugin like this.Changed line commented out:
//private static ThreadLocal<MustacheSession> session_ = new ThreadLocal<MustacheSession>();
private static MustacheSession _session = null;
public static MustacheSession session(){
//return session_.get();
return _session;
}
public void onConfigurationRead(){
// some code
_session = new MustacheSession(compiler, root);
// some code
}
And it is working fine now in prod mode! I see no reason why it should have been in a ThreadLocal in the first place as the session gets initialized at startup!
your issue is difficult to reproduce so i'll give few pointers here. you have tried to eliminate of issue being env issue. so other possible issues could be
data issue: many times reason for production issue is usually difference in actual data and test data. check if its data issue which is casuing NPE.
code issue: Is there something at people.html.(line:22) causing issue. first try removing / altering that to check if thats causing issue. Or can you get source code of mustache (exact version which you are using) and see what object its trying to create and where its failing.
Properties file for different environments: do you have different proprties file for each env? If yes, have u missed on any property for prod env?
You have a NullPointerException on MustacheTags.java at line 32.
This means that you are probably calling a method of the Mustache library and passing a null value.
Try logging all the parameters you transfer to this method (MyStuff.java line 183?).
You can look at the source code of MustacheTags here, it might help you understand what values you are passing and what should be passed.