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.

NullPointerException when trying to parse parseUnboundedValueObject of a Map<String, Object>

See original GitHub issue

Clear description of my expectations versus reality I am using Javers with SpringBoot and Mongo DB. The object I’m saving in the Mongo DB is not of a flat structure. In fact it is quite complex: public class A { private final B b; private final C c; private final Map<String, List<E>> map; } My repository class looks like this: ` @JaversSpringDataAuditable public interface ARepository extends MongoRepository<A, String>{

@Query(value = "{'b.id' : ?0 }")
public Optional<A> findById(String id);

}

` I have simple service where I’d like to retrieve some info about object: who created/when etc

` @Service @RequiredArgsConstructor public class AService { private final Javers javers;

public String getInitSnapshot(String id) {
	QueryBuilder query = QueryBuilder.byClass(A.class);
	List<CdoSnapshot> snapshots = javers.findSnapshots(query.build());

	return javers.getJsonConverter().toJson(snapshots);
}

} `

And I have a tests to try it out:

` @ActiveProfiles(“test”) @SpringBootTest @Slf4j class AServiceTest { @Autowired private ARepository repository;

@Autowired
private AService service;


@Test
void testJavers() {
	repository.save(buildEntity());
	
	String info = service.getInitSnapshot("id");
	
	log.info(info);
	
	assertNotNull(info);
}

} `

Well, this doesn’t work. When Javers try to parse UnboundedValueObjectId of a Map<String, List<E>> .

Steps To Reproduce I have a **runnable test case ** which isolates the bug and allows Javers Core Team to easily reproduce it. I have pushed this test case to my fork of this repository:

Please feel free to fork out https://github.com/xytrams/javers-error

Javers’ Version 6.1.1

Additional context … Would be great if it could be fixed/dealt with.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
xytramscommented, Jun 15, 2021

https://github.com/javers/javers/pull/1104 I tried to do my best to demonstrate the problem

0reactions
alabotskicommented, Jan 26, 2022

@bartoszwalacik can you give links with examples java test spring jpa + javers

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointer exception while parsing JSON Map in java
By obj.get("name") , you try getting value by key name from a top-level of your json request, while it's a property of a...
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >
How to Handle NullPointerException in Java - freeCodeCamp
The reason you are getting this error is because we are trying to perform the length() operation on str1 which is null ....
Read more >
Using Map: System.NullPointerException: Attempt to de ...
NullPointerException : Attempt to de-reference a null object. Not an expert with Apex, but I was assuming this should work.
Read more >
Cannot invoke method equalsIgnoreCase() on null object
Hi, I am trying to read the csv file and fetch the headers and ... but I need to use Katalon, and it...
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