Hello again.
Eureka :)
I know what is wrong... The point is that I _actually_ was inserting
CollateralCarDTO inside Proposal entity. To be more precise, my
"copyFields" utility method was inserting Set<CollateralCarDTO> inside
Proposal's Set<CollateralCar>...
All this is happening because in runtime, Java does not see the
difference between Set<CollateralCarDTO> and Set<CollateralCar> as
(again - in runtime) they are both simple collection objects! (type
erasure)
My utility class is introspecting source and target bean and it is
trying to copy fields - if their types are equal. This is why it was
copying wrong collections, which result was that Proposal entity was
fed up with DTOs.
Sorry for bothering you!
2007/4/23, Witold Szczerba <pljosh.mail_at_gmail.com>:
> Hi there,
> today I have encountered very strange behavior, I am getting an
> exception TOPLINK-7009.
> As dar as I know such an exception should occur only, when someone
> tries to put non-entity class into entity, but I know that each
> property of entity should be simple object or another entity...
>
> The background: (Glassfish v2 b43)
> I have entities: Proposal, Collateral, CollateralCar (extends
> Collateral) and data transfer objects: ProposalDTO, CollateralDTO and
> CollateralCarDTO (extends CollateralDTO).
> Proposal contains Set<Collateral> and ProposalDTO contains Set<CollateralDTO>.
>
> I have methods: entity2dto and dto2entity, they are performing
> conversion, when I download ProposalDTO and then upload it back, when
> merging I am getting exception as below :(
>
> Do you have any idea what could be wrong? I am 100% positive there are
> no any xxxDTO inside any @Entity, however DTO's contains few simple
> @Entities sometimes (as far as I know this is legal, as serializable
> entities (100% eager properties) can be detached and used as any other
> objects...
>
> ----------------------------------------------
> EJB5018: An exception was thrown during an ejb invocation on
> [ProposalServiceBean]
> javax.ejb.EJBException
> at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3833)
> at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3733)
> at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3535)
> at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1318)
> at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1280)
> at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:197)
> at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:104)
> at $Proxy142.update(Unknown Source)
> 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:597)
> at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:125)
> at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:658)
> at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:198)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1821)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1681)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1063)
> at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:179)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:781)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:538)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2542)
> at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:502)
> Caused by: javax.persistence.PersistenceException: Exception
> [TOPLINK-7009] (Oracle TopLink Essentials - 2.0 (Build b43-beta3
> (04/18/2007))):
> oracle.toplink.essentials.exceptions.ValidationException
> Exception Description: Missing descriptor for
> [pl.ibpolsoft.sop.core.dto.CollateralCarDTO]. Verify that the
> descriptor has been properly registered with the Session.
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:338)
> at com.sun.enterprise.util.EntityManagerWrapper.flush(EntityManagerWrapper.java:635)
> at pl.ibpolsoft.sop.core.services.ProposalServiceBean.createMetaInf(ProposalServiceBean.java:369)
> at pl.ibpolsoft.sop.core.services.ProposalServiceBean.entity2dto(ProposalServiceBean.java:400)
> at pl.ibpolsoft.sop.core.services.ProposalServiceBean.update(ProposalServiceBean.java:104)
> at pl.ibpolsoft.sop.core.services.ProposalServiceBean.update(ProposalServiceBean.java:66)
> 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:597)
> at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1055)
> at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:163)
> at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2859)
> at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3950)
> at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:190)
> ... 17 more
> Caused by: Exception [TOPLINK-7009] (Oracle TopLink Essentials - 2.0
> (Build b43-beta3 (04/18/2007))):
> oracle.toplink.essentials.exceptions.ValidationException
> Exception Description: Missing descriptor for
> [pl.ibpolsoft.sop.core.dto.CollateralCarDTO]. Verify that the
> descriptor has been properly registered with the Session.
> at oracle.toplink.essentials.exceptions.ValidationException.missingDescriptor(ValidationException.java:1985)
> at oracle.toplink.essentials.internal.descriptors.DescriptorIterator.getDescriptorFor(DescriptorIterator.java:106)
> at oracle.toplink.essentials.internal.descriptors.DescriptorIterator.iterateReferenceObjectForMapping(DescriptorIterator.java:279)
> at oracle.toplink.essentials.mappings.CollectionMapping.iterateOnElement(CollectionMapping.java:621)
> at oracle.toplink.essentials.mappings.CollectionMapping.iterateOnRealAttributeValue(CollectionMapping.java:635)
> at oracle.toplink.essentials.internal.indirection.IndirectionPolicy.iterateOnAttributeValue(IndirectionPolicy.java:207)
> at oracle.toplink.essentials.internal.indirection.TransparentIndirectionPolicy.iterateOnAttributeValue(TransparentIndirectionPolicy.java:289)
> at oracle.toplink.essentials.mappings.ForeignReferenceMapping.iterate(ForeignReferenceMapping.java:571)
> at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.iterate(ObjectBuilder.java:2061)
> at oracle.toplink.essentials.internal.descriptors.DescriptorIterator.iterateReferenceObjects(DescriptorIterator.java:296)
> at oracle.toplink.essentials.internal.descriptors.DescriptorIterator.startIterationOn(DescriptorIterator.java:469)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOfWork.java:145)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:239)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:335)
> ... 31 more
>