You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Gus Heck <gu...@olin.edu> on 2003/12/19 23:43:24 UTC
NPE in OjbExtent
Well I made the mistake of trying to enter a bug in scarab again... and
again it wasted my time..... I wish you folks would get a bugzilla.
All the formatting was eaten by scarab, which of course makes stack
traces illegible. Again I am posting my bug here where it might be
possbile to understand it.
I had JDO working fine with a protype web app that just had a single PC
class. I added a second PC class that is supposed to manage Id's across
my application. Since the next ID number needs to persist it is a JDO
enhanced class as well. I suspect however it gets used substantially
earlier in the program, since it is referenced in several class
initializers. Now I am getting the following Exception when my IdManager
class tries to use an extent to get a list of instances (of class
IdManager). Each instance manages Id's for a single PC class. Before
reporting this I upgraded to the cvs checkout of RC5 (was using CVS of
RC4 compiled somewhere around 12/1) Both versions have this problem. I
tweaked the build to give you line numbers for the OJB stuff too.
java.lang.ExceptionInInitializerError
at
org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
at org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
Caused by: java.lang.NullPointerException
at org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
at
org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
at com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
Source)
at
com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown Source)
at org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
at
org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
... 11 more
Looking at the code It seems that OjbStoreManager is calling
connector.getBroker and getting null which it is then passing to the
OjbExtent constructor.
-Gus
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NPE in OjbExtent (solved)
Posted by Gus Heck <gu...@olin.edu>.
The solution is two fold:
1. I'm an Idiot. I forgot to start a transaction before requesting an
extent. duh. Starting a transaction fixes the problem.
2. OJB failed to notice this and proceeded happily on it's way and threw
a plain old vanilla, tell you nothing NPE.
So I've fixed my code and here is a fix for yours...
Index: src/jdori/org/apache/ojb/jdori/sql/OjbStoreConnector.java
===================================================================
RCS file:
/home/cvspublic/db-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbStoreConnector.java,v
retrieving revision 1.1
diff -u -r1.1 OjbStoreConnector.java
--- src/jdori/org/apache/ojb/jdori/sql/OjbStoreConnector.java 24 Dec
2002 12:06:01 -0000 1.1
+++ src/jdori/org/apache/ojb/jdori/sql/OjbStoreConnector.java 21 Jan
2004 20:52:23 -0000
@@ -62,6 +62,8 @@
import com.sun.jdori.Connector;
+import javax.jdo.JDOUserException;
+
/**
* OjbStoreConnector represents a OJB PB connection
*
@@ -214,6 +216,9 @@
*/
public PersistenceBroker getBroker()
{
+ if (broker == null) {
+ throw new JDOUserException("No transaction in progress.");
+ }
return broker;
}
HTH,
Gus
Gus Heck wrote:
> Any further thoughts?
>
> Gus Heck wrote:
>
>> Hi Thomas,
>>
>> I tried that, and I still seem to get the same problem.
>>
>> -Gus
>>
>> Thomas Mahler wrote:
>>
>>> Hi Gus,
>>>
>>> Gus Heck wrote:
>>>
>>>> Hi Thomas,
>>>>
>>>> I don't think I did anything exotic in terms of commands executed...
>>>>
>>>> public static IdManager findIdManager(Class c) {
>>>> if (!loadedOK) { // flag for lazy init
>>>
>>>
>>>
>>>
>>> // please try the following:
>>>
>>> // PersistenceManagerFactory pmf =
>>> PersistenceHelper.getPMF();
>>> PersistenceManagerFactory pmf = ObjStorePMF.getInstance();
>>>
>>>
>>>> IdManager.pm = pmf.getPersistenceManager();
>>>> System.out.println(IdManager.pm); // this does print a
>>>> PMWrapper object
>>>> Extent ex =
>>>> IdManager.pm.getExtent(IdManager.class,true); // <<<<< Exception here
>>>>
>>>> For reference:
>>>>
>>>> public static PersistenceManagerFactory getPMF() {
>>>> return pmf;
>>>> }
>>>>
>>>> pmf is loaded in a static initializer with this statement:
>>>>
>>>> pmf = new OjbStorePMF();
>>>>
>>>> Which I believe I lifted from the website somewhere.
>>>> PersistanceHelper is a non-instantiable class, and pmf is a public
>>>> final static, so there can be only one. The call to findIdManager
>>>> occurs when I try to create an instance of LocationImpl (a
>>>> non-persistant class) Location impl contains the line:
>>>>
>>>> private static IdManager idMgr =
>>>> IdManager.findIdManager(LocationBase.class);
>>>>
>>>> Moving this out of class init and into lazy initialization does
>>>> nothing but allow junit to print the full stack trace for each test
>>>> each time rather than one stack trace and several class not found
>>>> errors. This error occurs when the code is deployed to tomcat too,
>>>> so I don't beleive it is related to running under Junit.
>>>>
>>>> -Gus
>>>>
>>>> For reference here is my JDO file..
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data
>>>> Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd">
>>>>
>>>> <jdo>
>>>> <package name="org.cs101.fdb.impl.jdo">
>>>> <class name="IdManager"
>>>> identity-type="application"
>>>> > <!-- end class tag -->
>>>> </class>
>>>> <class name="LocationBase"
>>>> identity-type="application"
>>>> > <!-- end class tag -->
>>>> </class>
>>>> </package>
>>>>
>>>> <!--
>>>> To use additional vendor extensions, create a
>>>> vendor-extensions.xml file that
>>>> contains the additional extensions (in extension tags) and place
>>>> it in your
>>>> projects merge dir.
>>>> -->
>>>>
>>>> </jdo>
>>>>
>>>> and the repository.xml info for IdManager:
>>>>
>>>> <class-descriptor
>>>> class="org.cs101.fdb.impl.jdo.IdManager"
>>>> table="IdManager"
>>>> >
>>>> <field-descriptor
>>>> name="id"
>>>> column="id"
>>>> jdbc-type="INTEGER"
>>>> primarykey="true"
>>>> >
>>>> </field-descriptor>
>>>> <field-descriptor
>>>> name="className"
>>>> column="className"
>>>> jdbc-type="VARCHAR"
>>>> length="256"
>>>> >
>>>> </field-descriptor>
>>>> <field-descriptor
>>>> name="lastId"
>>>> column="lastId"
>>>> jdbc-type="INTEGER"
>>>> >
>>>> </field-descriptor>
>>>> </class-descriptor>
>>>>
>>>>
>>>> -gus
>>>>
>>>>
>>>> Thomas Mahler wrote:
>>>>
>>>>> Hi Gus,
>>>>>
>>>>> I assume that there is a wrong sequence of initialization calls.
>>>>> EIther in your code or in mine...
>>>>>
>>>>> By just looking at you stacktrace I don't get an idea what might
>>>>> have gone wrong.
>>>>>
>>>>> Please post the relevant code that provoke the error. It looks as
>>>>> if some things are not yet initialized when you try to access the
>>>>> connector....
>>>>>
>>>>> cu,
>>>>> Thomas
>>>>>
>>>>> Gus Heck wrote:
>>>>>
>>>>>> Well I made the mistake of trying to enter a bug in scarab
>>>>>> again... and again it wasted my time..... I wish you folks would
>>>>>> get a bugzilla.
>>>>>>
>>>>>> All the formatting was eaten by scarab, which of course makes
>>>>>> stack traces illegible. Again I am posting my bug here where it
>>>>>> might be possbile to understand it.
>>>>>>
>>>>>> I had JDO working fine with a protype web app that just had a
>>>>>> single PC class. I added a second PC class that is supposed to
>>>>>> manage Id's across my application. Since the next ID number needs
>>>>>> to persist it is a JDO enhanced class as well. I suspect however
>>>>>> it gets used substantially earlier in the program, since it is
>>>>>> referenced in several class initializers. Now I am getting the
>>>>>> following Exception when my IdManager class tries to use an
>>>>>> extent to get a list of instances (of class IdManager). Each
>>>>>> instance manages Id's for a single PC class. Before reporting
>>>>>> this I upgraded to the cvs checkout of RC5 (was using CVS of RC4
>>>>>> compiled somewhere around 12/1) Both versions have this problem.
>>>>>> I tweaked the build to give you line numbers for the OJB stuff too.
>>>>>>
>>>>>> java.lang.ExceptionInInitializerError
>>>>>> at
>>>>>> org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
>>>>>> at
>>>>>> org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
>>>>>> Caused by: java.lang.NullPointerException
>>>>>> at
>>>>>> org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>>>>>> at
>>>>>> org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
>>>>>>
>>>>>> at
>>>>>> com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
>>>>>> at
>>>>>> org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
>>>>>> ... 11 more
>>>>>>
>>>>>> Looking at the code It seems that OjbStoreManager is calling
>>>>>> connector.getBroker and getting null which it is then passing to
>>>>>> the OjbExtent constructor.
>>>>>>
>>>>>> -Gus
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NPE in OjbExtent
Posted by Gus Heck <gu...@olin.edu>.
Any further thoughts?
Gus Heck wrote:
> Hi Thomas,
>
> I tried that, and I still seem to get the same problem.
>
> -Gus
>
> Thomas Mahler wrote:
>
>> Hi Gus,
>>
>> Gus Heck wrote:
>>
>>> Hi Thomas,
>>>
>>> I don't think I did anything exotic in terms of commands executed...
>>>
>>> public static IdManager findIdManager(Class c) {
>>> if (!loadedOK) { // flag for lazy init
>>
>>
>>
>> // please try the following:
>>
>> // PersistenceManagerFactory pmf =
>> PersistenceHelper.getPMF();
>> PersistenceManagerFactory pmf = ObjStorePMF.getInstance();
>>
>>
>>> IdManager.pm = pmf.getPersistenceManager();
>>> System.out.println(IdManager.pm); // this does print a
>>> PMWrapper object
>>> Extent ex = IdManager.pm.getExtent(IdManager.class,true);
>>> // <<<<< Exception here
>>>
>>> For reference:
>>>
>>> public static PersistenceManagerFactory getPMF() {
>>> return pmf;
>>> }
>>>
>>> pmf is loaded in a static initializer with this statement:
>>>
>>> pmf = new OjbStorePMF();
>>>
>>> Which I believe I lifted from the website somewhere.
>>> PersistanceHelper is a non-instantiable class, and pmf is a public
>>> final static, so there can be only one. The call to findIdManager
>>> occurs when I try to create an instance of LocationImpl (a
>>> non-persistant class) Location impl contains the line:
>>>
>>> private static IdManager idMgr =
>>> IdManager.findIdManager(LocationBase.class);
>>>
>>> Moving this out of class init and into lazy initialization does
>>> nothing but allow junit to print the full stack trace for each test
>>> each time rather than one stack trace and several class not found
>>> errors. This error occurs when the code is deployed to tomcat too,
>>> so I don't beleive it is related to running under Junit.
>>>
>>> -Gus
>>>
>>> For reference here is my JDO file..
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data
>>> Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd">
>>>
>>> <jdo>
>>> <package name="org.cs101.fdb.impl.jdo">
>>> <class name="IdManager"
>>> identity-type="application"
>>> > <!-- end class tag -->
>>> </class>
>>> <class name="LocationBase"
>>> identity-type="application"
>>> > <!-- end class tag -->
>>> </class>
>>> </package>
>>>
>>> <!--
>>> To use additional vendor extensions, create a
>>> vendor-extensions.xml file that
>>> contains the additional extensions (in extension tags) and place
>>> it in your
>>> projects merge dir.
>>> -->
>>>
>>> </jdo>
>>>
>>> and the repository.xml info for IdManager:
>>>
>>> <class-descriptor
>>> class="org.cs101.fdb.impl.jdo.IdManager"
>>> table="IdManager"
>>> >
>>> <field-descriptor
>>> name="id"
>>> column="id"
>>> jdbc-type="INTEGER"
>>> primarykey="true"
>>> >
>>> </field-descriptor>
>>> <field-descriptor
>>> name="className"
>>> column="className"
>>> jdbc-type="VARCHAR"
>>> length="256"
>>> >
>>> </field-descriptor>
>>> <field-descriptor
>>> name="lastId"
>>> column="lastId"
>>> jdbc-type="INTEGER"
>>> >
>>> </field-descriptor>
>>> </class-descriptor>
>>>
>>>
>>> -gus
>>>
>>>
>>> Thomas Mahler wrote:
>>>
>>>> Hi Gus,
>>>>
>>>> I assume that there is a wrong sequence of initialization calls.
>>>> EIther in your code or in mine...
>>>>
>>>> By just looking at you stacktrace I don't get an idea what might
>>>> have gone wrong.
>>>>
>>>> Please post the relevant code that provoke the error. It looks as
>>>> if some things are not yet initialized when you try to access the
>>>> connector....
>>>>
>>>> cu,
>>>> Thomas
>>>>
>>>> Gus Heck wrote:
>>>>
>>>>> Well I made the mistake of trying to enter a bug in scarab
>>>>> again... and again it wasted my time..... I wish you folks would
>>>>> get a bugzilla.
>>>>>
>>>>> All the formatting was eaten by scarab, which of course makes
>>>>> stack traces illegible. Again I am posting my bug here where it
>>>>> might be possbile to understand it.
>>>>>
>>>>> I had JDO working fine with a protype web app that just had a
>>>>> single PC class. I added a second PC class that is supposed to
>>>>> manage Id's across my application. Since the next ID number needs
>>>>> to persist it is a JDO enhanced class as well. I suspect however
>>>>> it gets used substantially earlier in the program, since it is
>>>>> referenced in several class initializers. Now I am getting the
>>>>> following Exception when my IdManager class tries to use an extent
>>>>> to get a list of instances (of class IdManager). Each instance
>>>>> manages Id's for a single PC class. Before reporting this I
>>>>> upgraded to the cvs checkout of RC5 (was using CVS of RC4 compiled
>>>>> somewhere around 12/1) Both versions have this problem. I tweaked
>>>>> the build to give you line numbers for the OJB stuff too.
>>>>>
>>>>> java.lang.ExceptionInInitializerError
>>>>> at
>>>>> org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
>>>>> at org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
>>>>> Caused by: java.lang.NullPointerException
>>>>> at
>>>>> org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>>>>> at
>>>>> org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
>>>>>
>>>>> at
>>>>> com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown Source)
>>>>> at
>>>>> com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown
>>>>> Source)
>>>>> at
>>>>> org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
>>>>> at
>>>>> org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
>>>>> ... 11 more
>>>>>
>>>>> Looking at the code It seems that OjbStoreManager is calling
>>>>> connector.getBroker and getting null which it is then passing to
>>>>> the OjbExtent constructor.
>>>>>
>>>>> -Gus
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NPE in OjbExtent
Posted by Gus Heck <gu...@olin.edu>.
Hi Thomas,
I tried that, and I still seem to get the same problem.
-Gus
Thomas Mahler wrote:
> Hi Gus,
>
> Gus Heck wrote:
>
>> Hi Thomas,
>>
>> I don't think I did anything exotic in terms of commands executed...
>>
>> public static IdManager findIdManager(Class c) {
>> if (!loadedOK) { // flag for lazy init
>
>
> // please try the following:
>
> // PersistenceManagerFactory pmf = PersistenceHelper.getPMF();
> PersistenceManagerFactory pmf = ObjStorePMF.getInstance();
>
>
>> IdManager.pm = pmf.getPersistenceManager();
>> System.out.println(IdManager.pm); // this does print a
>> PMWrapper object
>> Extent ex = IdManager.pm.getExtent(IdManager.class,true);
>> // <<<<< Exception here
>>
>> For reference:
>>
>> public static PersistenceManagerFactory getPMF() {
>> return pmf;
>> }
>>
>> pmf is loaded in a static initializer with this statement:
>>
>> pmf = new OjbStorePMF();
>>
>> Which I believe I lifted from the website somewhere.
>> PersistanceHelper is a non-instantiable class, and pmf is a public
>> final static, so there can be only one. The call to findIdManager
>> occurs when I try to create an instance of LocationImpl (a
>> non-persistant class) Location impl contains the line:
>>
>> private static IdManager idMgr =
>> IdManager.findIdManager(LocationBase.class);
>>
>> Moving this out of class init and into lazy initialization does
>> nothing but allow junit to print the full stack trace for each test
>> each time rather than one stack trace and several class not found
>> errors. This error occurs when the code is deployed to tomcat too, so
>> I don't beleive it is related to running under Junit.
>>
>> -Gus
>>
>> For reference here is my JDO file..
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data
>> Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd">
>>
>> <jdo>
>> <package name="org.cs101.fdb.impl.jdo">
>> <class name="IdManager"
>> identity-type="application"
>> > <!-- end class tag -->
>> </class>
>> <class name="LocationBase"
>> identity-type="application"
>> > <!-- end class tag -->
>> </class>
>> </package>
>>
>> <!--
>> To use additional vendor extensions, create a
>> vendor-extensions.xml file that
>> contains the additional extensions (in extension tags) and place
>> it in your
>> projects merge dir.
>> -->
>>
>> </jdo>
>>
>> and the repository.xml info for IdManager:
>>
>> <class-descriptor
>> class="org.cs101.fdb.impl.jdo.IdManager"
>> table="IdManager"
>> >
>> <field-descriptor
>> name="id"
>> column="id"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> >
>> </field-descriptor>
>> <field-descriptor
>> name="className"
>> column="className"
>> jdbc-type="VARCHAR"
>> length="256"
>> >
>> </field-descriptor>
>> <field-descriptor
>> name="lastId"
>> column="lastId"
>> jdbc-type="INTEGER"
>> >
>> </field-descriptor>
>> </class-descriptor>
>>
>>
>> -gus
>>
>>
>> Thomas Mahler wrote:
>>
>>> Hi Gus,
>>>
>>> I assume that there is a wrong sequence of initialization calls.
>>> EIther in your code or in mine...
>>>
>>> By just looking at you stacktrace I don't get an idea what might
>>> have gone wrong.
>>>
>>> Please post the relevant code that provoke the error. It looks as if
>>> some things are not yet initialized when you try to access the
>>> connector....
>>>
>>> cu,
>>> Thomas
>>>
>>> Gus Heck wrote:
>>>
>>>> Well I made the mistake of trying to enter a bug in scarab again...
>>>> and again it wasted my time..... I wish you folks would get a
>>>> bugzilla.
>>>>
>>>> All the formatting was eaten by scarab, which of course makes stack
>>>> traces illegible. Again I am posting my bug here where it might be
>>>> possbile to understand it.
>>>>
>>>> I had JDO working fine with a protype web app that just had a
>>>> single PC class. I added a second PC class that is supposed to
>>>> manage Id's across my application. Since the next ID number needs
>>>> to persist it is a JDO enhanced class as well. I suspect however it
>>>> gets used substantially earlier in the program, since it is
>>>> referenced in several class initializers. Now I am getting the
>>>> following Exception when my IdManager class tries to use an extent
>>>> to get a list of instances (of class IdManager). Each instance
>>>> manages Id's for a single PC class. Before reporting this I
>>>> upgraded to the cvs checkout of RC5 (was using CVS of RC4 compiled
>>>> somewhere around 12/1) Both versions have this problem. I tweaked
>>>> the build to give you line numbers for the OJB stuff too.
>>>>
>>>> java.lang.ExceptionInInitializerError
>>>> at
>>>> org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
>>>> at org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
>>>> Caused by: java.lang.NullPointerException
>>>> at org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>>>> at
>>>> org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
>>>>
>>>> at
>>>> com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown Source)
>>>> at
>>>> com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown
>>>> Source)
>>>> at
>>>> org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
>>>> at
>>>> org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
>>>> ... 11 more
>>>>
>>>> Looking at the code It seems that OjbStoreManager is calling
>>>> connector.getBroker and getting null which it is then passing to
>>>> the OjbExtent constructor.
>>>>
>>>> -Gus
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NPE in OjbExtent
Posted by Thomas Mahler <th...@web.de>.
Hi Gus,
Gus Heck wrote:
> Hi Thomas,
>
> I don't think I did anything exotic in terms of commands executed...
>
> public static IdManager findIdManager(Class c) {
> if (!loadedOK) { // flag for lazy init
// please try the following:
// PersistenceManagerFactory pmf = PersistenceHelper.getPMF();
PersistenceManagerFactory pmf = ObjStorePMF.getInstance();
> IdManager.pm = pmf.getPersistenceManager();
> System.out.println(IdManager.pm); // this does print a
> PMWrapper object
> Extent ex = IdManager.pm.getExtent(IdManager.class,true); //
> <<<<< Exception here
>
> For reference:
>
> public static PersistenceManagerFactory getPMF() {
> return pmf;
> }
>
> pmf is loaded in a static initializer with this statement:
>
> pmf = new OjbStorePMF();
>
> Which I believe I lifted from the website somewhere. PersistanceHelper
> is a non-instantiable class, and pmf is a public final static, so there
> can be only one. The call to findIdManager occurs when I try to create
> an instance of LocationImpl (a non-persistant class) Location impl
> contains the line:
>
> private static IdManager idMgr =
> IdManager.findIdManager(LocationBase.class);
>
> Moving this out of class init and into lazy initialization does nothing
> but allow junit to print the full stack trace for each test each time
> rather than one stack trace and several class not found errors. This
> error occurs when the code is deployed to tomcat too, so I don't beleive
> it is related to running under Junit.
>
> -Gus
>
> For reference here is my JDO file..
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects
> Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd">
>
> <jdo>
> <package name="org.cs101.fdb.impl.jdo">
> <class name="IdManager"
> identity-type="application"
> > <!-- end class tag -->
> </class>
> <class name="LocationBase"
> identity-type="application"
> > <!-- end class tag -->
> </class>
> </package>
>
> <!--
> To use additional vendor extensions, create a vendor-extensions.xml
> file that
> contains the additional extensions (in extension tags) and place it
> in your
> projects merge dir.
> -->
>
> </jdo>
>
> and the repository.xml info for IdManager:
>
> <class-descriptor
> class="org.cs101.fdb.impl.jdo.IdManager"
> table="IdManager"
> >
> <field-descriptor
> name="id"
> column="id"
> jdbc-type="INTEGER"
> primarykey="true"
> >
> </field-descriptor>
> <field-descriptor
> name="className"
> column="className"
> jdbc-type="VARCHAR"
> length="256"
> >
> </field-descriptor>
> <field-descriptor
> name="lastId"
> column="lastId"
> jdbc-type="INTEGER"
> >
> </field-descriptor>
> </class-descriptor>
>
>
> -gus
>
>
> Thomas Mahler wrote:
>
>> Hi Gus,
>>
>> I assume that there is a wrong sequence of initialization calls.
>> EIther in your code or in mine...
>>
>> By just looking at you stacktrace I don't get an idea what might have
>> gone wrong.
>>
>> Please post the relevant code that provoke the error. It looks as if
>> some things are not yet initialized when you try to access the
>> connector....
>>
>> cu,
>> Thomas
>>
>> Gus Heck wrote:
>>
>>> Well I made the mistake of trying to enter a bug in scarab again...
>>> and again it wasted my time..... I wish you folks would get a bugzilla.
>>>
>>> All the formatting was eaten by scarab, which of course makes stack
>>> traces illegible. Again I am posting my bug here where it might be
>>> possbile to understand it.
>>>
>>> I had JDO working fine with a protype web app that just had a single
>>> PC class. I added a second PC class that is supposed to manage Id's
>>> across my application. Since the next ID number needs to persist it
>>> is a JDO enhanced class as well. I suspect however it gets used
>>> substantially earlier in the program, since it is referenced in
>>> several class initializers. Now I am getting the following Exception
>>> when my IdManager class tries to use an extent to get a list of
>>> instances (of class IdManager). Each instance manages Id's for a
>>> single PC class. Before reporting this I upgraded to the cvs checkout
>>> of RC5 (was using CVS of RC4 compiled somewhere around 12/1) Both
>>> versions have this problem. I tweaked the build to give you line
>>> numbers for the OJB stuff too.
>>>
>>> java.lang.ExceptionInInitializerError
>>> at
>>> org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
>>> at org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
>>> Caused by: java.lang.NullPointerException
>>> at org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>>> at
>>> org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
>>>
>>> at
>>> com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown Source)
>>> at
>>> com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown Source)
>>> at
>>> org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
>>> at
>>> org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
>>> ... 11 more
>>>
>>> Looking at the code It seems that OjbStoreManager is calling
>>> connector.getBroker and getting null which it is then passing to the
>>> OjbExtent constructor.
>>>
>>> -Gus
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NPE in OjbExtent
Posted by Gus Heck <gu...@olin.edu>.
Hi Thomas,
I don't think I did anything exotic in terms of commands executed...
public static IdManager findIdManager(Class c) {
if (!loadedOK) { // flag for lazy init
PersistenceManagerFactory pmf = PersistenceHelper.getPMF();
IdManager.pm = pmf.getPersistenceManager();
System.out.println(IdManager.pm); // this does print a
PMWrapper object
Extent ex = IdManager.pm.getExtent(IdManager.class,true); //
<<<<< Exception here
For reference:
public static PersistenceManagerFactory getPMF() {
return pmf;
}
pmf is loaded in a static initializer with this statement:
pmf = new OjbStorePMF();
Which I believe I lifted from the website somewhere. PersistanceHelper
is a non-instantiable class, and pmf is a public final static, so there
can be only one. The call to findIdManager occurs when I try to create
an instance of LocationImpl (a non-persistant class) Location impl
contains the line:
private static IdManager idMgr =
IdManager.findIdManager(LocationBase.class);
Moving this out of class init and into lazy initialization does nothing
but allow junit to print the full stack trace for each test each time
rather than one stack trace and several class not found errors. This
error occurs when the code is deployed to tomcat too, so I don't beleive
it is related to running under Junit.
-Gus
For reference here is my JDO file..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects
Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd">
<jdo>
<package name="org.cs101.fdb.impl.jdo">
<class name="IdManager"
identity-type="application"
> <!-- end class tag -->
</class>
<class name="LocationBase"
identity-type="application"
> <!-- end class tag -->
</class>
</package>
<!--
To use additional vendor extensions, create a vendor-extensions.xml
file that
contains the additional extensions (in extension tags) and place it
in your
projects merge dir.
-->
</jdo>
and the repository.xml info for IdManager:
<class-descriptor
class="org.cs101.fdb.impl.jdo.IdManager"
table="IdManager"
>
<field-descriptor
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
>
</field-descriptor>
<field-descriptor
name="className"
column="className"
jdbc-type="VARCHAR"
length="256"
>
</field-descriptor>
<field-descriptor
name="lastId"
column="lastId"
jdbc-type="INTEGER"
>
</field-descriptor>
</class-descriptor>
-gus
Thomas Mahler wrote:
> Hi Gus,
>
> I assume that there is a wrong sequence of initialization calls.
> EIther in your code or in mine...
>
> By just looking at you stacktrace I don't get an idea what might have
> gone wrong.
>
> Please post the relevant code that provoke the error. It looks as if
> some things are not yet initialized when you try to access the
> connector....
>
> cu,
> Thomas
>
> Gus Heck wrote:
>
>> Well I made the mistake of trying to enter a bug in scarab again...
>> and again it wasted my time..... I wish you folks would get a bugzilla.
>>
>> All the formatting was eaten by scarab, which of course makes stack
>> traces illegible. Again I am posting my bug here where it might be
>> possbile to understand it.
>>
>> I had JDO working fine with a protype web app that just had a single
>> PC class. I added a second PC class that is supposed to manage Id's
>> across my application. Since the next ID number needs to persist it
>> is a JDO enhanced class as well. I suspect however it gets used
>> substantially earlier in the program, since it is referenced in
>> several class initializers. Now I am getting the following Exception
>> when my IdManager class tries to use an extent to get a list of
>> instances (of class IdManager). Each instance manages Id's for a
>> single PC class. Before reporting this I upgraded to the cvs checkout
>> of RC5 (was using CVS of RC4 compiled somewhere around 12/1) Both
>> versions have this problem. I tweaked the build to give you line
>> numbers for the OJB stuff too.
>>
>> java.lang.ExceptionInInitializerError
>> at
>> org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
>> at org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
>> Caused by: java.lang.NullPointerException
>> at org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>> at
>> org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
>>
>> at
>> com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown Source)
>> at
>> com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown Source)
>> at
>> org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
>> at
>> org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
>> ... 11 more
>>
>> Looking at the code It seems that OjbStoreManager is calling
>> connector.getBroker and getting null which it is then passing to the
>> OjbExtent constructor.
>>
>> -Gus
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Problem with new mapping inheritance solution (multiple joined tables)
Posted by "Nadir T." <na...@yahoo.com.br>.
Hye,
I have a problem with new inheritance mapping solution using multiple joined tables, where subclasses have a foreign key to superclass that is different from subclass primary key (solution: primary key + foreign key to superclass). Reading subclass objects works fine, but writing and updating only writes the subclass, the superclass values are not written to database. Final result is only an entry in subclass table.
Can anyone help me?
P.S: Does this mapping solution supports extents?
Thanks,
Nadir
---------------------------------
Central anti-spam do Yahoo! Mail: com dicas, dúvidas e curiosidades!
Re: NPE in OjbExtent
Posted by Thomas Mahler <th...@web.de>.
Hi Gus,
I assume that there is a wrong sequence of initialization calls. EIther
in your code or in mine...
By just looking at you stacktrace I don't get an idea what might have
gone wrong.
Please post the relevant code that provoke the error. It looks as if
some things are not yet initialized when you try to access the connector....
cu,
Thomas
Gus Heck wrote:
> Well I made the mistake of trying to enter a bug in scarab again... and
> again it wasted my time..... I wish you folks would get a bugzilla.
>
> All the formatting was eaten by scarab, which of course makes stack
> traces illegible. Again I am posting my bug here where it might be
> possbile to understand it.
>
> I had JDO working fine with a protype web app that just had a single PC
> class. I added a second PC class that is supposed to manage Id's across
> my application. Since the next ID number needs to persist it is a JDO
> enhanced class as well. I suspect however it gets used substantially
> earlier in the program, since it is referenced in several class
> initializers. Now I am getting the following Exception when my IdManager
> class tries to use an extent to get a list of instances (of class
> IdManager). Each instance manages Id's for a single PC class. Before
> reporting this I upgraded to the cvs checkout of RC5 (was using CVS of
> RC4 compiled somewhere around 12/1) Both versions have this problem. I
> tweaked the build to give you line numbers for the OJB stuff too.
>
> java.lang.ExceptionInInitializerError
> at
> org.cs101.fdb.impl.jdo.JDOFactory.createLocation(JDOFactory.java:32)
> at org.cs101.fdb.test.LocationTest.setUp(LocationTest.java:46)
> Caused by: java.lang.NullPointerException
> at org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
> at
> org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251)
>
> at com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
> Source)
> at
> com.sun.jdori.common.PersistenceManagerWrapper.getExtent(Unknown Source)
> at org.cs101.fdb.impl.jdo.IdManager.findIdManager(IdManager.java:63)
> at
> org.cs101.fdb.impl.jdo.LocationImpl.<clinit>(LocationImpl.java:51)
> ... 11 more
>
> Looking at the code It seems that OjbStoreManager is calling
> connector.getBroker and getting null which it is then passing to the
> OjbExtent constructor.
>
> -Gus
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org