CMP migration from Weblogic to Sun AppServer fails to Deploy
PROBLEM :
Post migration from BEA Weblogic to Sun Java system Application server, deployment fails with exceptions like below :
1.CLI171 Command deploy failed : Deploying application in domain failed; Fatal Error from EJB Compiler -- JDO74025: JDOCodeGenerator: Caught an Exception validat
ing CMP bean 'CustEJB' in application 'eApp' module 'date_wl': JDO72317: The field accountPMKey has an invalid fetch group.
Default is not a valid fetch group for managed fields. If your field is not a managed field, it may be treated as one if you have a CMR to this bean which is mapped to the same column as accountPMKey.
Select a different fetch group.
SOLUTION:
The sun cmp mappings expects to specify a fetch group for the managed fields
If there is no fetched-with subelement of a cmr-field-mapping, fetched-with can have any valid subelement. The default subelement is as follows:
<fetched-with><none/></fetched-with>
But, A managed field(Managed fields are multiple CMP or CMR fields that are mapped to the same database column) can have any fetched-with subelement except <default/>.
From the weblogic-cmp-rdbms-jar.xml(and sun-cmp-mappings.xml that is generated from it as a result of migration), accountPMKey field is managed as it has multiple cmp/cmr mappings to the same database column without a fetched-with declaration .
So, one shd be able to deploy successfully by declaring <fetched-with><none/></fetched-with> for all these CMRs in the sun-cmp-mappings.xml file .
About managed field:
A managed field is a CMP or CMR field that is mapped to the same database column as another CMP or CMR field. CMP fields mapped to the same column and CMR fields mapped to exactly the same column lists always have the same value in memory.
For CMR fields that share only a subset of their mapped columns, changes to the columns affect the relationship fields in memory differently. Basically, the Application Server always tries to keep the state of the objects in memory synchronized with the database.

