Spring AOP - Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
2009-10-13 08:07
1291 查看
今天在集成perf4j和javasimon到代码里的时候发现一些问题,就是本来在自己的测试代码里运行好好的东西,在放到项目代码里的时候总是报以下错误:
...
Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
...
比较了代码半天发现在自己的测试代码里没有用到有构造参数的spring bean,而在项目代码中很多的类都是通过有参数构造函数来创建的。而spring在借助cglib创建目标对象子类时,并没有对有参数构造函数做处理,而是使用的默认我参数构造函数,这就导致了以上异常的出现。要解决这个问题,比较简单的做法就是添加一个默认构造函数,当然前提是你的类允许你修改,但是对于一些不能有默认构造函数的类就比较麻烦了,比如第三方的类。这里有一个很详细的文章对这个问题做了描述,http://netfork.javaeye.com/blog/286215
...
Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
...
比较了代码半天发现在自己的测试代码里没有用到有构造参数的spring bean,而在项目代码中很多的类都是通过有参数构造函数来创建的。而spring在借助cglib创建目标对象子类时,并没有对有参数构造函数做处理,而是使用的默认我参数构造函数,这就导致了以上异常的出现。要解决这个问题,比较简单的做法就是添加一个默认构造函数,当然前提是你的类允许你修改,但是对于一些不能有默认构造函数的类就比较麻烦了,比如第三方的类。这里有一个很详细的文章对这个问题做了描述,http://netfork.javaeye.com/blog/286215
相关文章推荐
- Spring AOP - Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
- java.lang.IllegalArgumentException: Too many bind arguments. 1 arguments were provided but the stat
- java.lang.IllegalArgumentException: Too many bind arguments. 4 arguments were provided but the stat
- java.lang.IllegalArgumentException: Too many bind arguments. 4 arguments were provided but the stat
- java.lang.IllegalArgumentException: Too many bind arguments. 1 arguments were provided but the stat
- [错误]java.lang.IllegalArgumentException: Index for header 'XXX' is 1 but CSVRecord only has 1 val
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- Caused by: java.lang.IllegalArgumentException: Original must not be null
- 【Caused by: java.lang.IllegalArgumentException: Original must not be null 】
- mllib:java.lang.IllegalArgumentException: GiniAggregator given label 2.0 but requires label < numCla
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has
- java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has