JMeter 3.3连接Spark 2.2.1报错:无法创建PoolableConnectionFactory
Hey there, let's work through this JMeter 3.3 + Spark 2.2.1 connection issue together. I've run into similar driver compatibility hiccups with JMeter's classloading before, so here's a step-by-step fix based on the JARs you already know work with SQuirrel:
Unlike SQuirrel, which lets you specify driver JARs per connection, JMeter loads JDBC dependencies from specific directories. Copy all the JARs you listed into:
JMETER_HOME/lib/ext: This is the standard spot for extension libraries like JDBC drivers and their dependencies.
If you hit classloader conflicts later, you can move core low-level dependencies (like
hadoop-common-2.7.3.jarorlibthrift-0.9.3.jar) toJMETER_HOME/libinstead, but start withlib/extfirst.
The "Cannot create PoolableConnectionFactory" error often ties to misconfigured JDBC parameters. Verify these in your JMeter JDBC Connection Configuration element:
- JDBC Driver Class: Use
org.apache.hive.jdbc.HiveDriver(this is the correct driver for Spark 2.2.1's Hive-backed Thrift Server) - JDBC URL: Make sure it follows the Spark Thrift Server format:
Replace placeholders with your actual server details (default Thrift port is 10000; leavejdbc:hive2://<your-spark-host>:10000/<your-database>?user=<username>&password=<password><your-database>empty if using the default database).
JMeter's default classloader can sometimes load its own older dependencies (like commons-logging or httpclient) before your Spark/Hive JARs, causing conflicts. Fix this:
- Open
JMETER_HOME/bin/jmeter.propertiesin a text editor - Find the line
classloader.testplan_priority - Change its value to
true:classloader.testplan_priority=true
This forces JMeter to load your test plan's libraries (the ones in lib/ext) before its core system libraries.
After adding JARs and editing the properties file, close JMeter completely and restart it. Partial restarts won't pick up the new libraries or configuration changes.
If you still see the error, run JMeter with verbose classloading to spot conflicting JARs:
jmeter -verbose:class
Look for lines like [Loaded org.apache.commons.dbcp.PoolableConnectionFactory from ...]—if the class is loading from JMeter's default lib folder instead of your Spark/Hive JARs, delete the conflicting JAR from JMETER_HOME/lib (e.g., an older commons-dbcp JAR that comes with JMeter).
Once you've followed these steps, your JMeter connection should work just like it does in SQuirrel. The main issue here is JMeter's stricter classloading rules compared to SQuirrel—getting the JAR placement and classloader order right is key.
内容的提问来源于stack exchange,提问作者robert

