question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why Decoder Can Not Be Null?

See original GitHub issue

Hi, I’m trying to figure out why when querying/iterating a model/entity, I’m getting decoder can not be null as shown in the below stack trace? Other entities work, but this particular one isn’t so I’m trying to figure out why it isn’t working. Any ideas?

Caused by: java.lang.IllegalArgumentException: decoder can not be null
	at org.bson.assertions.Assertions.notNull(Assertions.java:35)
	at org.bson.codecs.DecoderContext.decodeWithChildContext(DecoderContext.java:95)
	at dev.morphia.mapping.codec.pojo.EntityDecoder.decodeModel(EntityDecoder.java:65)
	at dev.morphia.mapping.codec.pojo.EntityDecoder.decodeProperties(EntityDecoder.java:87)
	at dev.morphia.mapping.codec.pojo.EntityDecoder.decode(EntityDecoder.java:42)
	at dev.morphia.mapping.codec.pojo.MorphiaCodec.decode(MorphiaCodec.java:66)
	at dev.morphia.mapping.codec.pojo.EntityDecoder.decode(EntityDecoder.java:47)
	at dev.morphia.mapping.codec.pojo.MorphiaCodec.decode(MorphiaCodec.java:66)
	at com.mongodb.internal.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
	at com.mongodb.internal.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:60)
	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
	at org.bson.internal.LazyCodec.decode(LazyCodec.java:48)
	at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101)
	at com.mongodb.internal.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:63)
	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
	at com.mongodb.internal.connection.ReplyMessage.<init>(ReplyMessage.java:51)
	at com.mongodb.internal.connection.InternalStreamConnection.getCommandResult(InternalStreamConnection.java:412)
	at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:308)
	at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:258)
	at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
	at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:500)
	at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:71)
	at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:224)
	at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:202)
	at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:118)
	at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:110)
	at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:343)
	at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:334)
	at com.mongodb.internal.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:220)
	at com.mongodb.internal.operation.FindOperation$1.call(FindOperation.java:631)
	at com.mongodb.internal.operation.FindOperation$1.call(FindOperation.java:625)
	at com.mongodb.internal.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:462)
	at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:625)
	at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:77)
	at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:190)
	at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:135)
	at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92)
	at dev.morphia.query.MorphiaQuery.prepareCursor(MorphiaQuery.java:320)
	at dev.morphia.query.MorphiaQuery.iterator(MorphiaQuery.java:201)
	at dev.morphia.query.MorphiaQuery.iterator(MorphiaQuery.java:196)
Server Version: MongoDB, 4.0.22
Driver Version: mongo-java-driver|sync, version: "4.0.5" 
Morphia Version: morphia-core, 2.1.4

Note: It is a single node replication cluster using Wired Tiger storage engine.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
evanchoolycommented, Mar 4, 2021

Wow. It would have taken forever to suss that out here. Nice catch. Though it suggests I should add a test for that case. I’m pretty sure there’s a validation for conflicting mappings like that but I’m not sure it checks the cross-inheritance boundary like that.

0reactions
iAmcRcommented, Mar 4, 2021

Hi, figured it out. It’s pretty simple, I need to get some sleep!

The problem occurred because I had the repeated the same properties in the abstract class into the concrete class. For example, I had:

   @Property("p")
    public int pathetic;

in Errant and in SErrant. Morphia doesn’t like that and couldn’t determine which to use so essentially no decoder was set for that field.

Thanks a mil for clues and pointing me in the right direction. It’s very appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception "decoder can not be null" while using Morphia to ...
I am facing the following problem. I have created a Time Series collection in MongoDB and I have stored the following object:.
Read more >
Null value decoding in java · Issue #669 - GitHub
Hi guys, I fully agree with mjpt777. There should be a representation of the null value: null value means 'no value' and is...
Read more >
CharsetDecoder (Java SE 12 & JDK 12 ) - Oracle Help Center
The decode method returns when more input is required, when there is not enough room in the output buffer, or when a decoding...
Read more >
DECODE - Db2 SQL - IBM
If the NULL keyword is used as an argument in the DECODE function, it must be cast to a data type that is...
Read more >
nvJPEG - NVIDIA Documentation Center
The host phase of the decoding will not need to access to device resources. ... NULL is accepted, in which case the default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found