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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
