Search code examples
cassandracloud-foundryhector

What's different: running in local tomcat vs. in cloud foundry


I have an application that runs just fine in a local tomcat instance - it's a cassandra client app that uses Hector as a client library for Cassandra. The application creates a keyspace and column family (if it doesn't already exist) using code like the following:

final ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keySpaceName,
    columnFamilyName, ComparatorType.BYTESTYPE);
    cfDef.setKeyValidationClass(ComparatorType.LONGTYPE.getClassName());
    cfDef.setComparatorType(ComparatorType.UTF8TYPE);

cfDef.addColumnDefinition(new BasicColumnDefinition() {{
    setName(StringSerializer.get().toByteBuffer("id"));
    setValidationClass(ComparatorType.LONGTYPE.getClassName());
}});

When I push this exact same application to cloud foundry (our own internal cloud where we have a simple cassandra service), the line above with "addColumnDefinition" results in an exception - here's the stack trace:

java.lang.UnsupportedOperationException
java.util.AbstractList.add(Unknown Source)
java.util.AbstractList.add(Unknown Source)
me.prettyprint.cassandra.service.ThriftCfDef.addColumnDefinition(ThriftCfDef.java:311)
org.pvtl.cassandra.HectorSample.createColumnFamily(HectorSample.java:94)
org.pvtl.cassandra.HectorSample.<init>(HectorSample.java:37)
org.apache.jsp.index_jsp._jspService(index_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

A bunch of googling and it looks like the trouble is that the Hector code is trying to add to an immutable list - the java.util.AbstractList. But again, that code runs fine on my local tomcat instance so I'm thinking a difference in the jdk? Maybe? I'm running java 7 (sun) locally and pushed choosing java 7. Anyone have any ideas?


Solution

  • Most probably you are using a different version of Hector in your local tomcat than the one in the server (i.e. server has older library) because the immutable list constrain was removed from newer Hector versions

    See this pull request discussion

    Edit

    You might want to check your server configuration and make sure it has the latest hector library and/or check that hector-cor-xxx.jar does not exist under your tomcat/jetty libraries folder as it might cause dependency problem.