Re: null pointer exception while committing new object.

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Tue Jul 28 2009 - 13:39:09 EDT

  • Next message: sridhar devatha: "Re: null pointer exception while committing new object."

    What version of Cayenne are you using? Can we see the code you are
    performing before committing the context? Could you show part of DataMap
    declaration? Probably you are incorrectly registering persistent objects in
    Cayenne context. I'm afraid information you are currently providing is not
    enough to help you.

    2009/7/28 sridhar devatha <devatha.sridha..mail.com>

    > INFO QueryLogger: Created connection pool:
    > jdbc:derby://localhost:1527/empDB;create=false
    > Driver class: org.apache.derby.jdbc.ClientDriver
    > Min. connections in the pool: 1
    > Max. connections in the pool: 1
    > INFO QueryLogger: Opening connection:
    > jdbc:derby://localhost:1527/empDB;create=false
    > Login: fsau
    > Password: *******
    > INFO QueryLogger: +++ Connecting: SUCCESS.
    > INFO QueryLogger: Detected and installed adapter:
    > org.apache.cayenne.dba.derby.DerbyAdapter
    > Exception in thread "main" java.lang.NullPointerException
    > at
    >
    > org.apache.cayenne.CayenneDataObject.validateForSave(CayenneDataObject.java:551)
    > at
    >
    > org.apache.cayenne.CayenneDataObject.validateForInsert(CayenneDataObject.java:658)
    > at
    >
    > org.apache.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(ObjectStoreGraphDiff.java:100)
    > at
    > org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1217)
    > at
    > org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1138)
    > at
    > com.empApp.dao.impl.CayenneDAOImpl.commitChanges(CayenneDAOImpl.java:32)
    >
    > CayenneDAOImpl is as follows:
    > public abstract class CayenneDAOImpl {
    > private DataContext dc = null;
    > /**
    > * Returns thread-bound DataContext.
    > */
    > protected synchronized DataContext getDataContext() {
    > try {
    > if(dc == null){
    > dc = DataContext.getThreadDataContext();
    > }
    > } catch(IllegalStateException ISE){
    > dc = DataContext.createDataContext();
    > DataContext.bindThreadDataContext(dc);
    > }
    > return dc;
    > }
    >
    > synchronized protected void commitChanges(){
    > getDataContext().commitChanges();
    > }
    >
    > }
    >
    > On Tue, Jul 28, 2009 at 9:33 AM, Matt Kerr <mat..entralparksoftware.com
    > >wrote:
    >
    > > any chance you have a stack trace ?
    > > or code snippet ?
    > > project even ?
    > >
    > > very hard to offer suggestion / debug
    > > without more info :-?
    > >
    > > ok -thanks
    > > -matt
    > >
    > >
    > > On Mon, Jul 27, 2009 at 11:59 PM, sridhar
    > > devatha<devatha.sridha..mail.com> wrote:
    > > > Hi,
    > > >
    > > > I am getting null pointer exception while committing new object. I
    > > committed
    > > > several other objects of different classes using cayenne's
    > > > datacontext.commitchanges. But, i am unable to commit this object.
    > > >
    > > > --
    > > >
    > > > Yours Sincerely,
    > > > Sridhar
    > > >
    > >
    >
    >
    >
    > --
    >
    > Yours Sincerely,
    > Devatha Sridhar
    >



    This archive was generated by hypermail 2.0.0 : Tue Jul 28 2009 - 13:39:46 EDT