mguenther/kafka-junit

java.lang.NoClassDefFoundError: org/apache/kafka/server/authorizer/Authorizer

Closed this issue · 1 comments

I'm running the latest version in a simple java project, adding it to maven pom.
The code is the same as in the docs:

@Rule
public EmbeddedKafkaCluster cluster = provisionWith(useDefaults());
@Test
public void onMaxRetryReachedTest() throws InterruptedException, ExecutionException {

	Gson g = new Gson();
	List<String> list = new ArrayList<String>();	
	list.add(g.toJson(msg));
	List<RecordMetadata> metaList = cluster.send(new SendValues(TOPIC, list, null));
	
    RecordMetadata meta = metaList.get(0);
}

When running the test class, it never gets to my test, it fails at startup with exception:

java.lang.NoClassDefFoundError: org/apache/kafka/server/authorizer/Authorizer
at kafka.server.KafkaConfig$.(KafkaConfig.scala:520)
at kafka.server.KafkaConfig$.(KafkaConfig.scala)
at net.mguenther.kafka.junit.EmbeddedKafkaConfig$EmbeddedKafkaConfigBuilder.build(EmbeddedKafkaConfig.java:44)
at net.mguenther.kafka.junit.EmbeddedKafkaConfig.useDefaults(EmbeddedKafkaConfig.java:77)
at net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig$EmbeddedKafkaClusterConfigBuilder.(EmbeddedKafkaClusterConfig.java:16)
at net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.create(EmbeddedKafkaClusterConfig.java:51)
at net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.useDefaults(EmbeddedKafkaClusterConfig.java:55)
at com.tobprecise.spouts.RecordStatusKafkaTupleListenerTest.(RecordStatusKafkaTupleListenerTest.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.server.authorizer.Authorizer
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 30 more

Did you fix the issue?