Re: IllegalAccess When Setting Field
After doing some testing. I am finding that sometimes I get the exception, sometimes it works and sometimes the contactMech is populated with an instance of CPhoneNumber (which is what i want) and sometimes it just populates with CContactMech. CPhoneNumber extends CContactMech. I have modified the code on the server to use class hints. The only pattern I am finding is that I can retreive the PartyContactMech without an exception if the obejct was created during the life of the server process. If i start the server and retreive one that was not created during the life of the process then I get the exception. Sounds like it works fine when the objects are cached, but thats just an assumption. I also stopped using a the dynamic proxy for PartyContactMech. -chris worley I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) ... 30 more I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems storing the object. The exception is attached and below is my code and mapping. - Code Integer partyId =
Re: IllegalAccess When Setting Field
I have now removed proxy=dynamic from all my class descriptors and I no longer get the exception. After doing some testing. I am finding that sometimes I get the exception, sometimes it works and sometimes the contactMech is populated with an instance of CPhoneNumber (which is what i want) and sometimes it just populates with CContactMech. CPhoneNumber extends CContactMech. I have modified the code on the server to use class hints. The only pattern I am finding is that I can retreive the PartyContactMech without an exception if the obejct was created during the life of the server process. If i start the server and retreive one that was not created during the life of the process then I get the exception. Sounds like it works fine when the objects are cached, but thats just an assumption. I also stopped using a the dynamic proxy for PartyContactMech. -chris worley I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) ... 30 more I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems storing the object.
Re: IllegalAccess When Setting Field
Hi Chris, which version of OJB do you use? Normally OJB will generate a more detailed error log when field setting fails. Caused by: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech Did you post the whole stack trace with complete error log? regards, Armin Chris Worley wrote: I have now removed proxy=dynamic from all my class descriptors and I no longer get the exception. After doing some testing. I am finding that sometimes I get the exception, sometimes it works and sometimes the contactMech is populated with an instance of CPhoneNumber (which is what i want) and sometimes it just populates with CContactMech. CPhoneNumber extends CContactMech. I have modified the code on the server to use class hints. The only pattern I am finding is that I can retreive the PartyContactMech without an exception if the obejct was created during the life of the server process. If i start the server and retreive one that was not created during the life of the process then I get the exception. Sounds like it works fine when the objects are cached, but thats just an assumption. I also stopped using a the dynamic proxy for PartyContactMech. -chris worley I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Re: IllegalAccess When Setting Field
Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at
Re: IllegalAccess When Setting Field
Armin, My ojb version is 1.0.3. -chris worley Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown
Re: IllegalAccess When Setting Field
Hi, ok, now we have a more detailed error message: [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] Seems that OJB try to set the field in a correct way. You declare CContactMech as dynamic proxy and OJB try to set such an instance in CPartyContactMech. Think the field you declare in CPartyContactMech have to be an Interface if you want to use a normal dynamic proxy in this case reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMechIF auto-retreive=true auto-update=true foreignkey field-ref=contactMechId/ /reference-descriptor Why did you declare CContactMech class objects as proxy? Wouldn't it be better to use a proxy-reference for the 1:1 relation between CPartyContactMech and CContactMech? reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMech auto-retreive=true auto-update=true proxy=true foreignkey field-ref=contactMechId/ /reference-descriptor regards, Armin Chris Worley wrote: Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field
Re: IllegalAccess When Setting Field
Armin, I removed the dynamic proxy from the class descriptors and every thing works fine. I have not studied them enough to undertand how to handle them. -chris worley Hi, ok, now we have a more detailed error message: [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] Seems that OJB try to set the field in a correct way. You declare CContactMech as dynamic proxy and OJB try to set such an instance in CPartyContactMech. Think the field you declare in CPartyContactMech have to be an Interface if you want to use a normal dynamic proxy in this case reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMechIF auto-retreive=true auto-update=true foreignkey field-ref=contactMechId/ /reference-descriptor Why did you declare CContactMech class objects as proxy? Wouldn't it be better to use a proxy-reference for the 1:1 relation between CPartyContactMech and CContactMech? reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMech auto-retreive=true auto-update=true proxy=true foreignkey field-ref=contactMechId/ /reference-descriptor regards, Armin Chris Worley wrote: Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj
Re: IllegalAccess When Setting Field
Chris Worley wrote: Armin, I removed the dynamic proxy from the class descriptors and every thing works fine. I have not studied them enough to undertand how to handle them. In the upcoming 1.0.4 release it will be possible to use proxy handler classes based on cglib(enabled via OJB.properties file), these implementation classes allow the generation of dynamic proxies that do not require the persistent class to implement an interface. regards, Armin -chris worley Hi, ok, now we have a more detailed error message: [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] Seems that OJB try to set the field in a correct way. You declare CContactMech as dynamic proxy and OJB try to set such an instance in CPartyContactMech. Think the field you declare in CPartyContactMech have to be an Interface if you want to use a normal dynamic proxy in this case reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMechIF auto-retreive=true auto-update=true foreignkey field-ref=contactMechId/ /reference-descriptor Why did you declare CContactMech class objects as proxy? Wouldn't it be better to use a proxy-reference for the 1:1 relation between CPartyContactMech and CContactMech? reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMech auto-retreive=true auto-update=true proxy=true foreignkey field-ref=contactMechId/ /reference-descriptor regards, Armin Chris Worley wrote: Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
IllegalAccess When Setting Field
I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems storing the object. The exception is attached and below is my code and mapping. - Code Integer partyId = (Integer) getParameter(partyId); Criteria crit = new Criteria(); crit.addEqualTo(partyId, partyId); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); setParameter(partyContactMechs, getBroker().getCollectionByQuery(query)); Exception - Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech Mapping -- !-- Contact Mech -- class-descriptor class=net.enterprise.common.model.contact.CContactMech proxy=dynamic table=contact_mech field-descriptor name=contactMechId column=contact_mech_id jdbc-type=integer primarykey=true autoincrement=true / field-descriptor name=contactMechTypeId column=contact_mech_type_id jdbc-type=varchar / /class-descriptor !-- Party Contact Mech -- class-descriptor class=net.enterprise.common.model.party.CPartyContactMech proxy=dynamic table=party_contact_mech field-descriptor name=partyContactMechId column=party_contact_mech_id jdbc-type=integer primarykey=true autoincrement=true / field-descriptor name=partyId column=party_id jdbc-type=integer / field-descriptor name=contactMechId column=contact_mech_id jdbc-type=integer / field-descriptor name=fromDate column=from_date jdbc-type=timestamp / field-descriptor name=thruDate column=thru_date jdbc-type=timestamp / field-descriptor name=contactMechPurposeId column=contact_mech_purpose_id jdbc-type=integer / reference-descriptor name=contactMech class-ref=net.enterprise.common.model.contact.CContactMech auto-retreive=true auto-update=true foreignkey field-ref=contactMechId/ /reference-descriptor reference-descriptor name=party class-ref=net.enterprise.common.model.party.CParty auto-retreive=true auto-update=true foreignkey field-ref=partyId/ /reference-descriptor /class-descriptor thanks -chris worley org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech at