db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: Initialization of classes in Metadatamanager
Date Thu, 12 Feb 2004 20:36:11 GMT
Hi Gus,

Gus Heck wrote:

> It seems that in the process of loading MetadataManager each persistant 
> class is loaded with a class.forName(classname, true, 
> Thread.currentThread().getContextClassLoader()). (in 
> org.apache.ojb.broker.util.ClassHelper) I think the second argument true 
> is causing java to do a test initialization of the 0 arg constructor. Is 
> this neccessary? I am getting the following stack trace when I tried to 
> have a persistent class grab an ID from a static instance of my own 
> IDManager class. The result was an NPE in the *constructor* of my class 
> which really shouldn't be called until I actually instantiate an 
> instance. Since IdManager is itself persistant I can't set this value at 
> class initialization for the same reason....
> 
> Does passing true to class.forName have an important benefit that I am 
> not aware of?

For the pc objects AFAIK no! Interesting problem. All metadata classes 
use the 'initialize true' parameter. The class object was only loaded to 
verifiy the existence of the class on metadata read, no need to 
initialize the pc object.
Should we change this?

regards,
Armin

> 
> Gus
> 
> Exception in thread "main" java.lang.ExceptionInInitializerError
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(Class.java:219)
>        at 
> org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:21)
>        at 
> org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:89)
>        at 
> org.apache.ojb.broker.metadata.RepositoryXmlHandler.startElement(RepositoryXmlHandler.java:235)

> 
>        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1637)
>        at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
>        at 
> org.apache.crimson.parser.Parser2.externalParsedEntity(Parser2.java:2984)
>        at 
> org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2702)
>        at 
> org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2569) 
> 
>        at org.apache.crimson.parser.Parser2.content(Parser2.java:1980)
>        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
>        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
>        at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
>        at 
> org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
>        at 
> org.apache.ojb.broker.metadata.RepositoryPersistor.readMetadataFromXML(RepositoryPersistor.java:343)

> 
>        at 
> org.apache.ojb.broker.metadata.RepositoryPersistor.buildRepository(RepositoryPersistor.java:300)

> 
>        at 
> org.apache.ojb.broker.metadata.RepositoryPersistor.readDescriptorRepository(RepositoryPersistor.java:215)

> 
>        at 
> org.apache.ojb.broker.metadata.MetadataManager.init(MetadataManager.java:133) 
> 
>        at 
> org.apache.ojb.broker.metadata.MetadataManager.<init>(MetadataManager.java:123)

> 
>        at 
> org.apache.ojb.broker.metadata.MetadataManager.<clinit>(MetadataManager.java:112)

> 
>        at 
> org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.getDefaultKey(PersistenceBrokerFactoryBaseImpl.java:114)

> 
>        at 
> org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.defaultPersistenceBroker(PersistenceBrokerFactoryBaseImpl.java:196)

> 
>        at 
> org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker(PersistenceBrokerFactory.java:104)

> 
>        at 
> org.cs101.fdb.impl.jdo.PersistenceHelper.getDirectDBCon(PersistenceHelper.java:145) 
> 
>        at 
> org.cs101.fdb.impl.jdo.PersistenceHelper.<clinit>(PersistenceHelper.java:74) 
> 
>        at org.cs101.fdb.test.DbTestCase.<clinit>(DbTestCase.java:36)
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(Class.java:141)
>        at 
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:237)

> 
>        at 
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:210)

> 
>        at 
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:520)

> 
> Caused by: java.lang.NullPointerException
>        at org.cs101.fdb.impl.jdo.PersonBase.<init>(PersonBase.java:87)
>        at org.cs101.fdb.impl.jdo.PersonBase.<clinit>(PersonBase.java)
>        ... 32 more
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message