Container-managed persistence restrictions and exceptions

The container-managed persistence (CMP) features have certain restrictions when used in specific ways.

Enterprise bean deployment and Sybase IMAGE type restriction

When deploying enterprise beans with container managed persistence (CMP) types that are non-primitive and do not have a natural Java Database Connectivity (JDBC) mapping, the deployment tool maps the CMP type to a binary type in the database, where it is stored as a serialized instance. For Sybase, the tool uses the JDBC type LONG VARBINARY. The Sybase driver maps LONG VARBINARY to the native type IMAGE.

Although the type VARBINARY has fewer restrictions than IMAGE in Sybase, you cannot use it because it is limited to a size of 255 bytes, which is too small for typical serialized Java objects.

The specific restrictions on the IMAGE type are:

To work around this restriction, edit the EJB mappings in the WebSphere Studio Application Developer toolset and do either of the following:

A ClassCastException exception is thrown when running container managed persistence 1.1 beans

If you created your Enterprise JavaBeans (EJB) application using WebSphere Studio Application Developer or WebSphere Studio Application Developer Integration Edition, Version 4.0.x , and the application contains container managed persistence (CMP) 1.1 beans with associations (relationships), you might receive a java.lang.ClassCastException exception when you run your application on WebSphere Application Server Enterprise, Version 5.0.2 or later

The cast operation generated by WebSphere Studio Application Developer or WebSphere Studio Application Developer Integration Edition, Version 4.0.x does not use the javax.rmi.PortableRemoteObject.narrow(...) object to convert the remote object to the remote interface of CMP beans in the XToYLink.java (or YToXLink.java) class where X and Y are CMP 1.1 beans.

Recommended response

  1. Locate the following methods in all link classes, for example, XToYLink.java and YToXLink.javawhere X and Y are CMP 1.1 beans:
    public void secondaryAddElementCounterLinkOf(javax.ejb.EJBObject anEJB)
    public void secondaryRemoveElementCounterLinkOf(javax.ejb.EJBObject anEJB) 
    public void secondarySetCounterLinkOf(javax.ejb.EJBObject anEJB)
  2. Add the javax.rmi.PortableRemoteObject.narrow(...) object to convert the remote object to the remote interface of CMP beans.

For example, change the following original method:

public void secondaryAddElementCounterLinkOf(javax.ejb.EJBObject anEJB) throws java.rmi.RemoteException {
        if (anEJB != null) 
               ((X) anEJB).secondaryAddY((Y) getEntityContext().getEJBObject()); 
to:
public void secondaryAddElementCounterLinkOf(javax.ejb.EJBObject anEJB) throws java.rmi.RemoteException {
        if (anEJB != null)
             ((X) anEJB).secondaryAddY((Y)
javax.rmi.PortableRemoteObject.narrow(getEntityContext().getEJBObject(), Y.class)); 




Searchable topic ID:   rdat_cmptips
Last updated: Jun 21, 2007 4:55:42 PM CDT    WebSphere Application Server Network Deployment, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rdat_cmptips.html

Library | Support | Terms of Use | Feedback