I am creating a simple VO object and then trying to persist it into Mongo Database am getting NumberFormatException worst part is that exception is not being thrown from object itself as right now am not setting any properties of the object, this exception is killing me and am not sure how to deal it.
Here is the piece of code that is throwing exception:
public void testAgenda(){
ItemVO item = new ItemVO();
try {
item.persist();
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
e.getCause();
e.getMessage();
}
Here is the exception strace:
java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "4e3c3da5fbb7d7b41ce9e394"
at com.google.code.morphia.mapping.Mapper.updateKeyInfo(Mapper.java:194)
at com.google.code.morphia.DatastoreImpl.postSaveOperations(DatastoreImpl.java:742)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:645)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:685)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:679)
at com.williamblair.im.research.domain.vo.BaseDocument.persist(BaseDocument.java:68)
at com.williamblair.im.research.service.TestListService.testGetResearchAgenda_aroundBody2(TestListService.java:31)
at com.williamblair.im.research.service.TestListService$AjcClosure3.run(TestListService.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.williamblair.im.research.system.aop.profiling.ProfilingAspect.doProfiling(ProfilingAspect.java:36)
at com.williamblair.im.research.service.TestListService.testGetResearchAgenda(TestListService.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NumberFormatException: For input string: "4e3c3da5fbb7d7b41ce9e394"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:419)
at java.lang.Long.parseLong(Long.java:468)
at com.google.code.morphia.converters.LongConverter.decode(LongConverter.java:22)
at com.google.code.morphia.converters.TypeConverter.decode(TypeConverter.java:45)
at com.google.code.morphia.converters.DefaultConverters.decode(DefaultConverters.java:144)
at com.google.code.morphia.mapping.Mapper.setIdValue(Mapper.java:390)
at com.google.code.morphia.mapping.Mapper.updateKeyInfo(Mapper.java:174)
... 39 more
I have been debugging this issue for a while now and have not found the starting point yet, any suggestions?
Here is the persist method:
public void persist() {
this.morphiaDatastore.save(this);
}
Update
public class ItemVO {
@Id
private Long id;
private String name;
private double marketCap;
private Long analystId;
private Date dateAdded;
private boolean onResearch;
}
Stringfield which holds a hexstring in a database column which can only hold numerical values. Hex or not, strings are not numbers. - BalusCItemVOclass definition? I would like to see all the fields, methods and annotations. - Jesse Webb