Topic
  • 2 replies
  • Latest Post - ‏2012-12-19T22:19:10Z by lisaw
deravin
deravin
8 Posts

Pinned topic WebSphere 6.1 and Indexes specified using Spring

‏2012-12-12T19:10:03Z |
I have a web app (containing XS Client using 8.5 distro) that runs:

  • Under Tomcat 7 (SUN JRE6.xx.37) and
  • Websphere AS 6.1.0.29 (IBM JRE1.5)

Tomcat 7
========

Under Tomcat 7 things work fine.

From the Container Server I am able to retrieve the keys, using an index (shown below as <bean id="MapIndexPlugin" and defines index: productCode):

the call:
Collection queryByName = gs.queryByName(MyServiceImpl.ACCOUNT_POSITIONS, "productCode", productCode);

my method:
@Override
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Collection<T> queryByName(String mapName, String index, String name) {
try {
Session s = txManager.getSession();
s.setTransactionIsolation(Session.TRANSACTION_READ_COMMITTED);
setTimeOut(s);
LOGGER.fine(" QueryByName: TXID: " + s.getTxID()
+ ", TXISO=" + s.getTransactionIsolation() + ", TIMEOUT="
+ s.getTransactionTimeout());
ObjectMap m = s.getMap(mapName);
MapRangeIndex idx = (MapRangeIndex) m.getIndex(index);

ArrayList<Object> keysToFind = new ArrayList<Object>();
LOGGER.finest("index to key"+ idx);
for (Iterator<Object> empCodeIterator = idx.findAll(name); empCodeIterator
.hasNext();) {
Object next = empCodeIterator.next();
LOGGER.finest("Got by name-"+ next);
keysToFind.add(next);
}
return m.getAll(keysToFind);

} catch (Exception e) {
LOGGER.severe("queryByName failed: Map:" + mapName+ " Exception="+ e.getCause().getMessage() + e.getMessage());
throw new ObjectGridRuntimeException(e.getMessage(), e);
}
}

Under Websphere AS 6.1.0.29 :
=============================

The very presence of MapIndexPlugin leads to the exception, during inserts, shown below. Once the MapIndexPlugin is removed, CRUD operations begin to work.

<backingMap name="AccountPositions" pluginCollectionRef="CommonPluginsAP"
lockStrategy="PESSIMISTIC" copyMode="COPY_TO_BYTES_RAW"
numberOfLockBuckets="50" evictionTriggers="MEMORY_USAGE_THRESHOLD" />

<backingMapPluginCollections>
<backingMapPluginCollection id="CommonPluginsAP">
<bean id="Evictor"
className="com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor">
<property name="maxSize" type="int" value="3"
description="set max size for each LRU queue" />
<property name="sleepTime" type="int" value="15"
description="evictor thread sleep time" />
<property name="numberOfLRUQueues" type="int" value="43261"
description="set number of LRU queues" />
</bean>
<bean id="MapIndexPlugin" className="com.ibm.websphere.objectgrid.plugins.index.HashIndex">
<property name="Name" type="java.lang.String" value="productCode"
description="index on" />
<property name="RangeIndex" type="boolean" value="true"
description="true for MapRangeIndex" />
<property name="AttributeName" type="java.lang.String"
value="productCode" description="productCode" />
<property name="POJOKeyIndex" type="boolean" value="true"
description="productCode" />
</bean>

<bean id="MapEventListener" className="{spring}mapListener" />
</backingMapPluginCollection>
Exception:
==========

Dec 12, 2012 11:50:52 AM com.ibm.websphere.objectgrid.plugins.index.HashIndex
WARNING: GENERAL_EXCEPTION_WARNING_CWOBJ0006
12/12/12 11:50:52:780 EST 00000018 HashIndex W CWOBJ0006W: An exception occurred: com.ibm.websphere.objectgrid.ObjectGridRuntimeException: java.io.StreamCorruptedException: invalid type code: 00
at com.ibm.ws.objectgrid.map.BaseMap.bytesToObject(BaseMap.java:12423)
at com.ibm.ws.objectgrid.map.BaseMap.getValueCopyForTransaction(BaseMap.java:4858)
at com.ibm.ws.objectgrid.map.BaseMap.getValueCopyForTransaction(BaseMap.java:4815)
at com.ibm.ws.objectgrid.DiffMapValue.getCurrentValue(DiffMapValue.java:790)
at com.ibm.ws.objectgrid.DiffMapValue.getCurrentValue(DiffMapValue.java:747)
at com.ibm.ws.objectgrid.DiffMapValue.getAfterImage(DiffMapValue.java:1362)
at com.ibm.websphere.objectgrid.plugins.index.HashIndex.undoBatchUpdate(HashIndex.java:1637)
at com.ibm.ws.objectgrid.map.BaseMap.undoApplyPMap(BaseMap.java:2690)
at com.ibm.ws.objectgrid.SessionImpl.rollbackPMapChanges(SessionImpl.java:2358)
at com.ibm.ws.objectgrid.SessionImpl.commit(SessionImpl.java:1883)
at com.ibm.ws.objectgrid.ServerCoreEventProcessor.processLogSequence(ServerCoreEventProcessor.java:1601)
at com.ibm.ws.objectgrid.ServerCoreEventProcessor.processReadWriteTransactionRequest(ServerCoreEventProcessor.java:1490)
at com.ibm.ws.objectgrid.ServerCoreEventProcessor.processClientServerRequest(ServerCoreEventProcessor.java:2023)
at com.ibm.ws.objectgrid.ShardImpl.processMessage(ShardImpl.java:1001)
at com.ibm.ws.objectgrid.partition.IDLShardPOA._invoke(IDLShardPOA.java:191)
at com.ibm.CORBA.poa.POAServerDelegate.dispatchToServant(POAServerDelegate.java:402)
at com.ibm.CORBA.poa.POAServerDelegate.internalDispatch(POAServerDelegate.java:334)
at com.ibm.CORBA.poa.POAServerDelegate.dispatch(POAServerDelegate.java:256)
at com.ibm.rmi.iiop.ORB.process(ORB.java:513)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1574)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2845)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2718)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:63)
at com.ibm.ws.objectgrid.thread.ORBThreadPool$1.run(ORBThreadPool.java:82)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.StreamCorruptedException: invalid type code: 00
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
at java.math.BigDecimal.readObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.ibm.ws.objectgrid.plugins.GenericSerializationInfo.inflate(GenericSerializationInfo.java:84)
at com.ibm.ws.objectgrid.map.BaseMap$BaseMapObjectTransformer2.inflateObject(BaseMap.java:6678)
at com.ibm.ws.objectgrid.map.BaseMap$BaseMapObjectTransformer.inflateValue(BaseMap.java:6519)
at com.ibm.ws.objectgrid.map.BaseMap.bytesToObject(BaseMap.java:12342)
... 26 more

Please help. Is there a way to retain the index and still make CRUD operations work within WebSphere AS 6.1.0.29?

Thanks,

Vinay Soni
Software Engineer,
Fidelity Management Research
vinay.soni@fmr.com
Updated on 2012-12-19T22:19:10Z at 2012-12-19T22:19:10Z by lisaw
  • jhanders
    jhanders
    261 Posts

    Re: WebSphere 6.1 and Indexes specified using Spring

    ‏2012-12-14T04:09:42Z  
    Vinay,

    What you are doing should work. There have been a few fixes with COPY_TO_BYTES function as of late that may be pertinent to your issue where we fixed a StreamCorruptedException with the COPY_TO_BYTES function. The specific scenario that was fixed is where the grid was restarted, but the client was left running and then the grid was restarted.

    In general when using the COPY_TO_BYTES function without providing your own DataSerializer, it is frowned upon to use COPY_TO_BYTES with a MapIndexPlugin since the object needs to be inflated from bytes to a POJO in order to do the index on the server which add a lot of overhead. The DataSerializer function allows you to code your byte format in a way that can allow you to pull out fields by navigating to them directly instead of having to inflate the entire POJO object in order to get the needed attribute. You can find two samples of DataSerializers on the IBM Elastic Caching Community web site: http://www.ibm.com/developerworks/connect/caching/. From Download, select Samples.

    For your particular problem, I am wondering if your client and server have different class files. My question is there a difference between the client and server JVM related to a Java agent being used? Specifically are the classes that are stored in the grid JPA entities that are instrumented using a Java agent where the classes are annotated with additional fields and possibly changed to have a readObject/writeObject added where that isn't the case on the server JVM? We have seen where this causes problems with the built-in COPY_TO_BYTES code.

    I hope this helps to give some direction to what the problem is. Let us know if you have more questions.

    Jared Anderson
  • lisaw
    lisaw
    101 Posts

    Re: WebSphere 6.1 and Indexes specified using Spring

    ‏2012-12-19T22:19:10Z  
    • jhanders
    • ‏2012-12-14T04:09:42Z
    Vinay,

    What you are doing should work. There have been a few fixes with COPY_TO_BYTES function as of late that may be pertinent to your issue where we fixed a StreamCorruptedException with the COPY_TO_BYTES function. The specific scenario that was fixed is where the grid was restarted, but the client was left running and then the grid was restarted.

    In general when using the COPY_TO_BYTES function without providing your own DataSerializer, it is frowned upon to use COPY_TO_BYTES with a MapIndexPlugin since the object needs to be inflated from bytes to a POJO in order to do the index on the server which add a lot of overhead. The DataSerializer function allows you to code your byte format in a way that can allow you to pull out fields by navigating to them directly instead of having to inflate the entire POJO object in order to get the needed attribute. You can find two samples of DataSerializers on the IBM Elastic Caching Community web site: http://www.ibm.com/developerworks/connect/caching/. From Download, select Samples.

    For your particular problem, I am wondering if your client and server have different class files. My question is there a difference between the client and server JVM related to a Java agent being used? Specifically are the classes that are stored in the grid JPA entities that are instrumented using a Java agent where the classes are annotated with additional fields and possibly changed to have a readObject/writeObject added where that isn't the case on the server JVM? We have seen where this causes problems with the built-in COPY_TO_BYTES code.

    I hope this helps to give some direction to what the problem is. Let us know if you have more questions.

    Jared Anderson
    Jared mentioned two samples to check out for writing your own serializer. Here is a link to view both a BSON and Google Protobuf example.

    IBM Elastic Caching Community Serializer Samples

    • Lisa

    Websphere eXtreme Scale Development