spring和hibernate用到很多第三方的jar包。你必须保证这些包都在classpath地下了。如果是个webapp就应该放到web-inf/lib地下。上面的错误是,spring的aop用到的是一个aopalliance.jar的包,而它找不到。建议你把spring发行版本里的要求的lib文件都包含到classpath里面去。

解决方案 »

  1.   

    我把aopalliance.jar包加到lib目录下后,上面的信息好像是没有了但又出现了以下信息:
    2004-09-19 17:50:01,907 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in resource [/WEB-INF/dataAccessContext-local.xml] of ServletContext: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy
    java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy
    但在java中我一步一步按下来,到最后没有发现有NamingStrategy啊?这到底是why啊?
      

  2.   

    1. aopalliance 是必须。。
    还有java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy请你加入hibernate.jar
    虽然Spring 也提供了hibernate 两者还是有点差别的。。