When i create an object, it commits it correctly, however, when i edit it, i obtain the following exception:
12:32:20.244 [http-nio-8082-exec-9] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is JaversException SNAPSHOT_SERIALIZATION_ERROR: error while serializing snapshot of 'com.tesicnor.tcheck.equipment.data.model.Equipment/92849', duplicated property 'Field ValueType:String equipmentStatus, declared in Detectable'] with root cause
org.javers.common.exception.JaversException: SNAPSHOT_SERIALIZATION_ERROR: error while serializing snapshot of 'com.tesicnor.tcheck.equipment.data.model.Equipment/92849', duplicated property 'Field ValueType:String equipmentStatus, declared in Detectable'
My entity Equipment contains an equipmentStatus, and this entity extends from another one, named Detectable, which also contains a equipmentStatus field. However there are more fields where the same occurs. Any idea of how solving this error?
When you put two fields with the same name into one class - you are asking for trouble. It's the antipattern. Javers serializes object snapshots as a Map: propertyName -> propertyValue. Obviously, if you have duplicted fields a Snapshot can't be serialized properly. Try to remove duplicated field.
Related
I have two list objects and want to check that the first items of each are equal. However, I get a NullPointerException at this line:
assertEquals(instance.getPlane(0), planes.get(0));
This is the entire stack trace:
Testcase: testGetPlane(mypackage.PlaneTest): Caused an ERROR
null
java.lang.NullPointerException
at mypackage.PlaneTest.testGetPlane(PlaneTest.java:60)
(Line 60 is the assertion.)
Neither of those objects are null. I'm having a separate issue getting the debugger to work, so instead I added these printouts to my test case:
System.err.println("equals? " + instance.getPlane(0).equals(planes.get(0)));
System.err.println("equals? " + planes.get(0).equals(instance.getPlane(0)));
However, those lines executed without throwing any errors!
I've cleaned and built the project and restarted Netbeans, but still have this issue.
JUnit just calls expected.equals(actual), which should be exactly the same thing as my printouts that aren't throwing the error, right? Why would assertEquals throw a NullPointerException, but equals on the same objects would not?
(I was about to post the question alone when I discovered the fix, but since it was a pain I'm posting it anyways in hopes this may help someone else. I did not find any other questions which had this solution.)
The error is in fact caused by JUnit, when it tries to compose an error message.
In the format function, there are the lines:
String expectedString = String.valueOf(expected);
String actualString = String.valueOf(actual);
if (expectedString.equals(actualString)) { ... }
String.valueOf(Object obj) returns obj.toString() if obj is not null.
My object's toString method simply returned a "name" field, which was never set inside the test. So, the object was not null, but the function returned null. This caused the NullPointerException when JUnit tried to call expectedString.equals. Ensuring that toString never returns null fixed the error.
I have to create a a new exception (MultipleErrorException) which extends MySuperException class. I have another exception (SingleErrorException) which also extends MySuperException.
Looking at the pseudo code below:
for (a number of times)
try
call myMethod(myObject) that throws SingleErrorException
catch(SingleErrorException e)
add the caught SingleErrorException object to a
MultipleErrorException object where a mapping should
be created mapping myObject to SingleErrorException
I need to throw a single "MultipleErrorException" which holds a map (myObject-->SingleErrorExceptions).
Is there any other way to this rather than creating an initial MultipleErrorException object before the for loop, an then adding the mappings as the exceptions are caught?
Thanks
java.lang.Exception as such does not have any method to support your requirement.
If you need it, then one way is to add the Map variable in MultipleErrorException and setting the value of it, but again, editing the exception object is not good.
Instead, you can add the error messages to Map and return the map instead of throwing the exception from the method.
I want to create a custom exception message in case exception is thrown by my mule service. In order to do that, i want to separately capture mule generated ErrorCode. Is there any property using which i can get that value? I tried using #[org.mule.config.ExceptionHelper.getErrorCode(Exception.class)]" but this returned -1 as a value instead of the actual exception code.
What method can i use to fetch ErrorCode?
You are supposed to pass the class of the current exception, ie:
#[org.mule.config.ExceptionHelper.getErrorCode(exception.class)]"
exception is the current exception while Exception is the java.lang.Exception class for which there is no error code associated.
I'm getting the following error when creating a new record/model:
Uncaught Error: Attempted to handle event `willSetProperty` on <App.NewsItem:ember361:null> while in state rootState.loaded.created.inFlight. Called with {reference: [object Object], store: <App.Store:ember299>, name: bodyHTML}
What does it mean?
Seems to be caused by the application updating a property (called 'bodyHTML') on an instance of a model of type App.NewsItem while it is being saved (rootState.loaded.created.inFlight). I have no idea why I'm receiving the error on creation though.
Seems like either you are modifying an existing dirty object , or you are trying setting some property to undefined
see
http://coryforsyth.com/2013/06/10/the-willsetproperty-gotcha-in-ember-data-understanding-the-state-machine/
I have a class DataFile which is the top level class that I am serializing. DataFile contains an ArrayCollection which in-turn contains objects which extend ArrayData, each which overrides readExternal in different ways.
Over the course of the development the ArrayData object from version 1.0 is now different than the ArrayData object in version 1.1.
This causes deserialization to fail, most often with a null object error.
This is expected behavior. What I would like to happen is that in cases where an error occurs the object would simply be ignored and we would continue deserialization.
To effect this I have thrown try..catch logic into the deserialization for the ArrayData
override public function readExternal(input:IDataInput):void {
try {
testvalue = input.readObject();
newTestValue = input.readObject(); //a value that is not a part of the file being deserialized
catch(e:Error){
//an error occurred, but just keep going
}
}
I was hoping that this would allow the deserialization chain to continue doing its thing and then would allow me to clean up the broken data after everything has been deserialized.
The problem I am now having is that the serialization of the ArrayCollection fails immediately after an error is caught in a bad ArrayData object with a index out of bounds error.
Error #2006: The supplied index is out
of bounds.
I have tried faking data in the catch portion of te ArrayData object but nothing works. I don't know why the error is bubbling up the deserialization chain and I do not know how to prevent this.
If anyone has any ideas on where I should go next in an attempt to resolve this issue I would appreciate the feedback.
Thanks,
Dan