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: Factory in class descriptor is not always used?
Date Fri, 23 Jul 2004 11:32:32 GMT
Hi Sergey,

thanks for detailed description. I agree with with you that it's a bug. 
I will check in your bug fix asap.

regards,
Armin


Sergey Udovenko wrote:
> Hi,
> 
> I'm using factory to construct my persistent classes. All the classes are
> with protected constructors.
> I've defined factory-class and factory-method in class-descriptor.
> Everything worked fine until I didn't add references.
> Now, trying to save my object, I got the following exception:
> 
> 
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.metadata.MetadataException:
> java.lang.IllegalAccessException: Class
> org.apache.ojb.broker.util.ClassHelper can not access a member of class
> fis.FisDomainModel.impl.LegalEntityImpl with modifiers "protected"
> 	at
> org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(TransactionImpl.java:
> 932)
> 	at org.apache.ojb.odmg.TransactionImpl.lock(TransactionImpl.java:235)
> 	at ojb.Main.memberOrg(Main.java:114)
> 	at ojb.Main.main(Main.java:58)
> Caused by: org.apache.ojb.broker.metadata.MetadataException:
> java.lang.IllegalAccessException: Class
> org.apache.ojb.broker.util.ClassHelper can not access a member of class
> fis.FisDomainModel.impl.LegalEntityImpl with modifiers "protected"
> 	at
> org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentFieldForInheri
> tance.get(AnonymousPersistentFieldForInheritance.java:86)
> 	at
> org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(TransactionImpl.java:
> 926)
> 	... 3 more
> Caused by: java.lang.IllegalAccessException: Class
> org.apache.ojb.broker.util.ClassHelper can not access a member of class
> fis.FisDomainModel.impl.LegalEntityImpl with modifiers "protected"
> 	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
> 	at java.lang.Class.newInstance0(Class.java:302)
> 	at java.lang.Class.newInstance(Class.java:261)
> 	at org.apache.ojb.broker.util.ClassHelper.newInstance(ClassHelper.java:113)
> 	at org.apache.ojb.broker.util.ClassHelper.newInstance(ClassHelper.java:268)
> 	at
> org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentFieldForInheri
> tance.get(AnonymousPersistentFieldForInheritance.java:79)
> 	... 4 more
> 
> 
> I guess that I'm getting it because the base class supposed to be created by
> the factory as well (ctor is protected).
> The problem is in method AnonymousPersistentFieldForInheritance.get() that
> uses ClassHelper.newInstance(cld.getBaseClass()); to create that base class.
> I've tried following fix and it worked for my case (all junit test was green
> too):
> 
> 		    // old
>                 //value = ClassHelper.newInstance(cld.getBaseClass());
> 
>                 ClassDescriptor baseCld =
> cld.getRepository().getDescriptorFor(cld.getBaseClass());
>                 value = ClassHelper.buildNewObjectInstance(baseCld);
> 
> 
> Would you consider it's a bug or am I just missing something?
> 
> 
> thanks,
> Sergey Udovenko
> 
> 
> ---------------------------------------------------------------------
> 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