java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721)
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
at net.thucydides.core.steps.StepFactory.createProxyStepLibrary(StepFactory.java:155)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:109)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:101)
at net.thucydides.core.steps.StepFactory.getStepLibraryFor(StepFactory.java:67)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:50)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:41)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:23)
at net.thucydides.jbehave.ThucydidesStepFactory.createInstanceOfType(ThucydidesStepFactory.java:80)
at org.jbehave.core.steps.StepCreator.stepsInstance(StepCreator.java:82)
at org.jbehave.core.steps.StepCreator$ParameterisedStep.perform(StepCreator.java:550)
at org.jbehave.core.embedder.StoryRunner$FineSoFar.run(StoryRunner.java:499)
at org.jbehave.core.embedder.StoryRunner.runStepsWhileKeepingState(StoryRunner.java:479)
at org.jbehave.core.embedder.StoryRunner.runScenarioSteps(StoryRunner.java:443)
at org.jbehave.core.embedder.StoryRunner.runCancellable(StoryRunner.java:305)
at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:219)
at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:180)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:229)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:201)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
superclass has no null constructors but no arguments were given without spring integration
1.7k views Asked by Kaki Prasad At
2
There are 2 answers
0
On
Im not sure this problem was solved, but i managed to understand my problem:
java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
with following code:
public class CglibTest {
@Test
public void shouldCreateDynamicProxy() {
Enhancer enh = new Enhancer();
enh.setSuperclass(CgPlay.class);
enh.setCallback((FixedValue) () -> "fixedValueFromProxy");
CgPlay cgPlay = (CgPlay) enh.create();
System.out.println(cgPlay.fooStringPar(null));
}
class CgPlay {
public String fooStringPar(String s) {
return "fooStringPar";
}
}
}
It turned out, the CGLib had problem with CgPlay class, since it was a non-static member inner class. Making CgPlay class a static class, or non-memeber class solved issue.
You have a class that is calling the constructor of his implemented class by using super(), with no arguments in it.
Your super class doesn't have a constructor without any arguments.
Example:
The
super()
in the Cat class will call a constructor with no arguments of the Animal class. The Animal class doesn't have such a constructor and thus will throw an error like yours.This can also be caused if you are letting a framework like Spring, try to autowire an object, that doesn't have a no-argument constructor.
Please share the class the is throwing the error.