I’m trying to set up a connection pool in GlassFish for Cassandra using cassandra-jdbc driver. I’ve put the driver jar (and all of the jars that it depends on) in the ~glassfish-domain/lib/ext folder but I get the following error when I try to ping:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.cassandra.cql.jdbc.CassandraDriver Could not initialize class org.apache.cassandra.cql.jdbc.CassandraDriver
It seems that GlassFish finds the class, but can’t load it. As all of the dependencies are satisfied, a possible reason is that there is an exception in a static block. I checked the code of CassandraDriver and it actually has a static block:
static
{
// Register the CassandraDriver with DriverManager
try
{
CassandraDriver driverInst = new CassandraDriver();
DriverManager.registerDriver(driverInst);
}
catch (SQLException e)
{
throw new RuntimeException(e.getMessage());
}
}
Thanks in advance!
It seems that slf4j wasn’t loading correctly because it depends on log4j.jar. So I after adding it in the classpath, everything seems to be working fine. Here’s the list of all of the jars in my lib:
apache-cassandra-1.1.6.jar
apache-cassandra-clientutil-1.1.6.jar
apache-cassandra-thrift-1.1.6.jar
cassandra-jdbc-1.1.2.jar
commons-lang-2.4.jar
guava-r08.jar
libthrift-0.7.0.jar
log4j-1.2.14.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.8.jar