Primary Key error in Porting from Weblogic to Sun App Server

Hi,

This is regarding the porting of an application running on Weblogic8 to Sun One App Server.

My scenario is:

We are defining a base Key interface, let's say BaseKey, which is having some base fields, which should be present in every derived key, like :

publicabstractclass BaseKeyImplimplements BaseKey

{

private ApplicationContext applicationContext;

private String applicationDN;

private Object primaryKey;

private String type;

...............

...............

...............

publicvoid setPrimaryKey (String obj)throws IllegalArgumentException

{

if(obj ==null)

{

thrownew IllegalArgumentException("BaseKeyImpl: setPrimaryKey: Invalid value passed.");

}

primaryKey = obj;

}

}

Now, An inherited key class is something like:

publicclass ItemKeyImplextends BaseKeyImpl

{

public String itemPrimaryKey =null;

public String getItemPrimaryKey ()

{

return itemPrimaryKey;

}

publicvoid setItemPrimaryKey (String pKey)throws IllegalArgumentException

{

itemPrimaryKey = pKey;

super.setPrimaryKey(pKey);

}

........................

........................

}

And the Entity class is like :

publicinterface ItemValueEntityextends EJBObject

{

public String getItemPrimaryKey ()throws IllegalStateException, RemoteException;

publicvoid setItemPrimaryKey (String key)throws IllegalArgumentException, RemoteException;

public ItemKey getItemKey ()throws IllegalStateException, RemoteException;

publicvoid setItemKey (ItemKey pKey)throws IllegalArgumentException, RemoteException;

public ItemKey makeItemKey ()throws RemoteException;

......................

......................

}

In sun-cmp-mappings.xml, the mapping is like:

<entity-mapping>

<ejb-name>ItemValue</ejb-name>

<table-name>ITEMVALUE</table-name>

<cmp-field-mapping>

<field-name>itemPrimaryKey</field-name>

<column-name>ITEMKEY</column-name>

</cmp-field-mapping>

<cmp-field-mapping>

<field-name>name</field-name>

<column-name>NAME</column-name>

</cmp-field-mapping>

</entity-mapping>

Where I don't have to store BaseKey data members in database.

It is working fine on WebLogic8. Now I am deploying it on Sun One App Server. When I am verifying the application with Sun App Server verifier it is giving me a failed Tests.

Test Name : tests.ejb.runtime.cmpmapping.ASCmpMappingTest

Test Assertion :

Test Description : For [ RI#RI.jar#ItemValueEntity ]

Error: Entity bean [ ItemValueEntityBean ] has the following error(s) [

JDO72348: The type of non-static field applicationContext of the key class is invalid, resulting in an invalid generated key class ItemValueEntityBean558592343_JDOState$Oid. Valid types are: String, a Number type, or a Date type. If you have a user defined primary key class,

the type may also be primitive.

Update the type of the key class field.

].

And I should not make the BaseKeyImpl's members as Static.

Can anybody help me out, how to resolve this failed test.

Would appreciate your helping hand.

Thanks in advance,

Amitabh.

[5239 byte] By [amitabhta] at [2008-1-19]
# 1
As per section 10.8.2 of EJB 2.1 spec, All fields in the primary key class must be declared as public. The names of the fields in the PK class must be a subset of the names of the CMP fields.In your application the super class of primary key class has private fields.
Sudipto_Ghosha at 2007-7-10 > top of java,Enterprise & Remote Computing,AVK Portability...