google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

"bad type, not parameterized" when storing a self-defined object #244

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version are you using? (Morphia/Driver/MongoDB)
morphia-0.99.jar,  Driver mongo-2.5.jar,  MongoDB 1.6.3

I tried to store Jimmy Lin's HMapSIWSoft class for Hadoop (extended from 
HMapKISoft class and MapKISoft interface) to MongoDB using Morphia. I think the 
problem is related to the specific java class because I have tried other typed 
primitive classes (Vector, Array) and there was no error. The self-defined 
class is StemProb.java. The executable class is TestMapping.java. 

The reproduced error is as follows:

Mar 14, 2011 11:36:30 PM com.google.code.morphia.logging.MorphiaLoggerFactory 
chooseLoggerFactory
INFO: LoggerImplFactory set to 
com.google.code.morphia.logging.jdk.JDKLoggerFactory
com.google.code.morphia.mapping.MappingException: Could not map entity to 
DBObject
        at com.google.code.morphia.Morphia.toDBObject(Morphia.java:136)
        at edu.uchicago.naivetagger.debug.TestMapping.main(TestMapping.java:68)
        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)
Caused by: com.google.code.morphia.mapping.MappingException: Error mapping 
field:edu.uchicago.naivetagger.debug.StemProb.probability
        at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:444)
        at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:426)
        at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:417)
        at com.google.code.morphia.Morphia.toDBObject(Morphia.java:134)
        ... 10 more
Caused by: java.lang.RuntimeException: bad type, not parameterized...
        at com.google.code.morphia.utils.ReflectionUtils.isPropertyType(ReflectionUtils.java:194)
        at com.google.code.morphia.mapping.MappedField.discover(MappedField.java:102)
        at com.google.code.morphia.mapping.MappedField.<init>(MappedField.java:78)
        at com.google.code.morphia.mapping.MappedClass.discover(MappedClass.java:166)
        at com.google.code.morphia.mapping.MappedClass.<init>(MappedClass.java:110)
        at com.google.code.morphia.mapping.Mapper.getMappedClass(Mapper.java:200)
        at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:432)
        at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:426)
        at com.google.code.morphia.mapping.EmbeddedMapper.toDBObject(EmbeddedMapper.java:38)
        at com.google.code.morphia.mapping.Mapper.writeMappedField(Mapper.java:531)
        at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:442)

Original issue reported on code.google.com by shee...@gmail.com on 15 Mar 2011 at 4:52

Attachments:

GoogleCodeExporter commented 9 years ago
What version are you using? (Morphia/Driver/MongoDB)
morphia-1.00-SNAPSHOT.jar,  Driver mongo-2.5.3.jar,  MongoDB 1.8.1

I'm having exactly the same issue:

java.lang.ExceptionInInitializerError
    at at.ac.tuwien.ec.morphiaerrors.persistence.MongodbPersistence.<init>(MongodbPersistence.java:18)
    at at.ac.tuwien.ec.morphiaerrors.test.PersistenceTest.setUp(PersistenceTest.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    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.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    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.RuntimeException: Error initializing MongoDB
    at at.ac.tuwien.ec.morphiaerrors.config.MongoDB.<init>(MongoDB.java:22)
    at at.ac.tuwien.ec.morphiaerrors.config.MongoDB.<clinit>(MongoDB.java:10)
    ... 26 more
Caused by: java.lang.RuntimeException: bad type, not parameterized...
    at com.google.code.morphia.utils.ReflectionUtils.isPropertyType(ReflectionUtils.java:194)
    at com.google.code.morphia.mapping.MappedField.discover(MappedField.java:102)
    at com.google.code.morphia.mapping.MappedField.<init>(MappedField.java:78)
    at com.google.code.morphia.mapping.MappedClass.discover(MappedClass.java:166)
    at com.google.code.morphia.mapping.MappedClass.<init>(MappedClass.java:110)
    at com.google.code.morphia.mapping.Mapper.addMappedClass(Mapper.java:141)
    at com.google.code.morphia.Morphia.map(Morphia.java:55)
    at com.google.code.morphia.Morphia.mapPackage(Morphia.java:91)
    at com.google.code.morphia.Morphia.mapPackage(Morphia.java:72)
    at at.ac.tuwien.ec.morphiaerrors.config.MongoDB.<init>(MongoDB.java:18)
    ... 27 more

java.lang.NullPointerException
    at at.ac.tuwien.ec.morphiaerrors.test.PersistenceTest.tearDown(PersistenceTest.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.RunAfters.evaluate(RunAfters.java:37)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    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.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    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)

I've also created a simple test application illustrating the problem: 
https://github.com/xeraa/morphia-errors
As soon as I'm using "@Reference protected List<TEmployee> subordinate;" I'm 
running into this stackdump.

Is there any timeline for this issue? We'd really require it... Thanks!

Original comment by P.Xeraa@gmail.com on 8 Apr 2011 at 5:46

GoogleCodeExporter commented 9 years ago
I was also seeing this error, don't know if it helps anyone else but in my case 
it was because the pojo I was attempting to store extended another class that 
was much more complex. As soon as I remove my pojo from the parent everything 
was nifty.

Original comment by mnsol...@gmail.com on 2 May 2011 at 1:46

GoogleCodeExporter commented 9 years ago
I just encountered this by calling with datastore.save with the wrong 
parameters. I am just learning the syntax and called: 

MyClass mc = new MyClass();
datastore.save(MyClass.class, mc);

It choked on mapping some feature of the Class object, changing it to 
ds.save(mc) obviously worked.

Caused by: java.lang.RuntimeException: bad type, not parameterized...
      at com.google.code.morphia.utils.ReflectionUtils.isPropertyType(ReflectionUtils.java:194)
      at com.google.code.morphia.mapping.MappedField.discover(MappedField.java:102)
      at com.google.code.morphia.mapping.MappedField.<init>(MappedField.java:78)
      at com.google.code.morphia.mapping.MappedClass.discover(MappedClass.java:166)
      at com.google.code.morphia.mapping.MappedClass.<init>(MappedClass.java:110)
      at com.google.code.morphia.mapping.Mapper.getMappedClass(Mapper.java:200)
      at com.google.code.morphia.mapping.Mapper.getCollectionName(Mapper.java:208)
      at com.google.code.morphia.DatastoreImpl.getCollection(DatastoreImpl.java:546)
      at com.google.code.morphia.DatastoreImpl.getCollection(DatastoreImpl.java:553)
      at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:792)
      at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:787)
      at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:711)

Original comment by ketterl...@gmail.com on 13 Sep 2011 at 4:10