Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1964475
  • 博文数量: 606
  • 博客积分: 9991
  • 博客等级: 中将
  • 技术积分: 5725
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-17 19:07
文章分类

全部博文(606)

文章存档

2011年(10)

2010年(67)

2009年(155)

2008年(386)

分类:

2008-10-04 14:42:36

1.异常代码:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Line 5 in XML document from class path resource [hello.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
 
源文件部分代码:
hello.xml:

   xmlns:xsi=""
   xsi:schemaLocation="
       ">
   .......
 
解决方法:
缺少spring 2.x的jar,spring 1.x的jar不适合。
或者把hello.xml改为:

.....
 
 
2.异常代码:
The type org.aopalliance.aop.Advice cannot be resolved. It is indirectly  referenced from required .class files
 
源文件部分代码:
public class MinstrelAdvice implements MethodBeforeAdvice {
  public void before(Method method, Object[] args, Object target)
      throws Throwable {
       .......
   }
}
 
解决方法:
引入spring.jar(下带的org.aopalliance.*),因为Spring的aop的实现遵守了AOP联盟的约定,也就是它的切片都实现了org.aopalliance.aop.Advice接口
 
3.异常代码:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [Chapter01/resources/knight.xml]; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/JoinPoint
Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/JoinPoint
 
源文件部分代码:
 
   
                id="questPointcut"
          expression="execution(* *.embarkOnQuest(..)) and target(bean)" />
                method="singBefore"
          pointcut-ref="questPointcut"
          arg-names="bean" />
                method="singAfter"
          pointcut-ref="questPointcut"
          arg-names="bean" />
   
 
 
解决方法:
引入aspect系列包(下载地址:,)下载后解压,把lib文件夹下面的aspectjlib.jar,aspectjrt.jar,aspectjtools.jar,aspectjweaver.jar载入。
 
4.异常代码:
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
 
分析:
这个不是错误,是警告你没有定义log4j的配置文件安。
因为spirng本身是用log4j做日志记录的。
 
解决方法:
add   一个log4j.jar

增加一个配置文件:log4j.properties(放在src下)

内容是:
log4j.rootLogger=DEBUG,   stdout 
 
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%c{1}   -   %m%n
 
5.异常代码:
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
 at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy.instantiateWithMethodInjection(CglibSubclassingInstantiationStrategy.java:70)
 
源文件部分代码:













 
分析:
If take out the lookup-method all three beans are instantiated no problem.
解决方法:
加入 cglib-nodep-2.1_3.jar包
 
6.异常代码:
[org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect]: cannot use @Configurable. Root cause: java.lang.ClassNotFoundException: org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect
Caused by:
java.lang.IllegalStateException: Unable to load aspect class [org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect ]: cannot use @Configurable. Root cause: java.lang.ClassNotFoundException: org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect
    at org.springframework.aop.config.SpringConfiguredBeanDefinitionParser.getBeanConfigurerClass (SpringConfiguredBeanDefinitionParser.java:63)
 
源文件部分代码:
spring.xml
...
....
 
Instrumentalist .java
@Configurable("pianist")
public class Instrumentalist implements Performer {
  .....
}
 
分析:
if you trying to use @Configurable annotation in project,add spring-aspects.jar.
解决方法:
加入 spring-aspects.jar包
 
7.异常代码:
分析:
ehcache的一个bug引起的,把ehcache升级到1.2以上的版本就行了
解决方法:
原来项目中使用了ehcache-1.1.jar文件,
把它换成ehcache-1.2.3.jar文件
 
8.异常代码
java.lang.NoSuchMethodException: org.apache.struts2.spring.StrutsSpringObjectFactory. ()
Caused by:
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.struts2.spring.StrutsSpringObjectFactory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.apache.struts2.spring.StrutsSpringObjectFactory. ()
Caused by:
java.lang.NoSuchMethodException: org.apache.struts2.spring.StrutsSpringObjectFactory. ()
at java.lang.Class.getConstructor0(Class.java:2647)
at java.lang.Class.getDeclaredConstructor(Class.java:1953)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:759)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:724)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
分析:
在被依赖注入的类中少了构造函数
解决方法:
添加一个构造函数public Task(){}
阅读(4420) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~