Menu

ORDBException

Help Java
Beuti
2011-05-02
2013-05-29
  • Beuti

    Beuti - 2011-05-02

    Hi,
    we get an exception when trying to do the following :

    import java.io.File;
    import org.neodatis.odb.ODB;
    import org.neodatis.odb.ODBFactory;
    import org.neodatis.odb.OdbConfiguration;
    import server.PluginController;
    public class TestProg2 {
        /**
         * @param args
         */
        public static void main(String[] args) {        
            ThreadTest tTest = new ThreadTest(1);
    
            ODB odb = null;
            try {
                odb = ODBFactory.open("testODB.odb");
                odb.store(tTest);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (odb != null)
                    odb.close();
            }
        }
    }
    class ThreadTest extends Thread{
        private int testNr;
        public ThreadTest(int testNr)
        {
            this.testNr = testNr;
        }
    
        /**
         * @param testNr the testNr to set
         */
        public void setTestNr(int testNr) {
            this.testNr = testNr;
        }
        /**
         * @return the testNr
         */
        public int getTestNr() {
            return testNr;
        }
    }
    

    This is just example code, we realized the behavior in another class inheriting from thread.

    this is the stack trace

    org.neodatis.odb.ODBRuntimeException: 
    NeoDatis has thrown an Exception, please help us filling a bug report at https://sourceforge.net/tracker/?func=add&group_id=179124&atid=887885 with the following error message
    Version=1.9.30 , Build=689, Date=10-11-2010-08-21-21, Thread=main
    NeoDatisError:228:Error while creating (reflection) class [Ljava.security.cert.Certificate;
    StackTrace:
        at org.neodatis.odb.impl.core.layers.layer2.instance.ODBClassPool.getClass(ODBClassPool.java:82)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.AbstractClassIntrospector.introspect(AbstractClassIntrospector.java:521)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getClassInfo(LocalObjectIntrospector.java:434)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.introspectMap(LocalObjectIntrospector.java:408)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getNativeObjectInfoInternal(LocalObjectIntrospector.java:140)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfoInternal(LocalObjectIntrospector.java:267)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfoInternal(LocalObjectIntrospector.java:279)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfo(LocalObjectIntrospector.java:102)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.introspectArray(LocalObjectIntrospector.java:486)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getNativeObjectInfoInternal(LocalObjectIntrospector.java:127)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfoInternal(LocalObjectIntrospector.java:267)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfoInternal(LocalObjectIntrospector.java:279)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfoInternal(LocalObjectIntrospector.java:279)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getObjectInfo(LocalObjectIntrospector.java:102)
        at org.neodatis.odb.impl.core.layers.layer1.introspector.LocalObjectIntrospector.getMetaRepresentation(LocalObjectIntrospector.java:89)
        at org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine.internalStore(AbstractStorageEngine.java:554)
        at org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine.store(AbstractStorageEngine.java:438)
        at org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine.store(AbstractStorageEngine.java:420)
        at org.neodatis.odb.impl.main.ODBAdapter.store(ODBAdapter.java:113)
        at server.data.TestProg2.main(TestProg2.java:23)
    Caused by: java.lang.ClassNotFoundException: [Ljava.security.cert.Certificate;
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.neodatis.odb.impl.core.layers.layer2.instance.ODBClassPool.getClass(ODBClassPool.java:75)
        ... 19 more
    

    Does anybody happen to know what the problem is? Could the interfaces InstantiationHelper and ParameterHelper help us here? We are new to neodatis and the documentation didn't help us….

    Thanks in advance!

     
  • Anonymous

    Anonymous - 2011-05-06

    Does nobody know the reasen or even better a solution to this problem?

     
  • Anonymous

    Anonymous - 2011-05-06

    *reason

     
  • Vyacheslav Rusakov

    hi,

    The error indicates that odb don't know Certificate class.
    You are saving entire thread and odb tries to store its internal state.

    Its not a good direction. Why you need to store so heavyweight object? (i don't see much sence in this operation)
    Use simple pojos (as with any orm solution).
    If you really need to store thread, i think it is better to simply use serialization.

     
  • Beuti

    Beuti - 2011-05-12

    Hi,

    we solved this problem now by implementing Runnable instead of inheriting Thread.

    But now we are getting an another problem, which I suppose is a bug in Neodatis.

    I've got a custom class (OuterClass) containing a Hashtable of String as key and another custom class (InnerClass) as value. This class is containing a Hashtable, too. This has a custom class (KeyClass) as key and a string as value.

    I have a little example of code which shows exactly the same structur as in my project.

    import java.util.Hashtable;
    public class OuterClass {
        public Hashtable<String, InnerClass> table;
        public OuterClass() {
            super();
            table = new Hashtable<String, InnerClass>();
        }
        public OuterClass(Hashtable<String, InnerClass> table) {
            super();
            this.table = table;
        }
    }
    
    import java.util.Hashtable;
    public class InnerClass {
        public Hashtable<KeyClass, String> table;
        public InnerClass() {
            super();
            table = new Hashtable<KeyClass, String>();
        }
    }
    
    public class KeyClass {
        public String key;
        public String description;
    
        public KeyClass(String key, String description) {
            super();
            this.key = key;
            this.description = description;
        }
    }
    

    When i now build a instance of the OuterClass with some values and i take the same instance of KeyClass for two different entries in the Hashtable in two different InnerClass objects i get an NullPointerException when i try to store the OuterClass object. If i take two different instances of the KeyClass this Exception isnt thrown.

    Example Main Class which has the described behavior:

    import java.io.File;
    import org.neodatis.odb.ODB;
    import org.neodatis.odb.ODBFactory;
    public class MainClass {
        /**
         * @param args
         */
        public static void main(String[] args) {
            OuterClass outer = new OuterClass();
            InnerClass inner1 = new InnerClass();
            InnerClass inner2 = new InnerClass();
            KeyClass key = new KeyClass("testkey", "testdescription");
            KeyClass key2 = new KeyClass("testkey1", "testdescription1");
    
            outer.table.put("identifier1", inner1);
            outer.table.put("identifier2", inner2);
    
            inner1.table.put(key, "testvalue1");
            inner2.table.put(key, "testvalue2");
    //      inner2.table.put(key2, "testvalue2");
    
            ODB odb = null; 
            odb = ODBFactory.open(new File("test.odb").getAbsolutePath());
    
            odb.store(outer);
    
            odb.close();
        }
    }
    

    This is the Exception which is thrown:

    Exception in thread "main" java.lang.NullPointerException
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.writeMap(AbstractObjectWriter.java:2705)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.writeNativeObjectInfo(AbstractObjectWriter.java:916)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.insertNativeObject(AbstractObjectWriter.java:1842)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.internalStoreObject(AbstractObjectWriter.java:1926)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.writeNonNativeObjectInfo(AbstractObjectWriter.java:1193)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.insertNonNativeObject(AbstractObjectWriter.java:1815)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.storeObject(AbstractObjectWriter.java:1906)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.internalStoreObjectWrapper(AbstractObjectWriter.java:2738)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.writeMap(AbstractObjectWriter.java:2708)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.writeNativeObjectInfo(AbstractObjectWriter.java:916)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.insertNativeObject(AbstractObjectWriter.java:1842)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.internalStoreObject(AbstractObjectWriter.java:1926)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.writeNonNativeObjectInfo(AbstractObjectWriter.java:1193)
        at org.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter.insertNonNativeObject(AbstractObjectWriter.java:1815)
        at org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine.internalStore(AbstractStorageEngine.java:564)
        at org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine.store(AbstractStorageEngine.java:438)
        at org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine.store(AbstractStorageEngine.java:420)
        at org.neodatis.odb.impl.main.ODBAdapter.store(ODBAdapter.java:113)
        at MainClass.main(MainClass.java:30)
    

    I've debugged the NeoDatis-code at the point the exception is thrown and i recognized that the problem is at AbstractObjectWriter.java:2702 : AbstractObjectInfo value = map.get(key);
    At the point where the Hashtable of the second InnerClass shoul be stored the map return null for the given key although the map contains the key and the value.

    Greetings

     

Log in to post a comment.