当前位置: 代码迷 >> Java Web开发 >> java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$Refle解决思路
  详细解决方案

java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$Refle解决思路

热度:1065   发布时间:2016-04-16 21:27:00.0
java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$Refle
我运行tomcat服务器。启动报错。请高人指导:
错误代码
2015-1-13 10:01:23 org.springframework.web.context.ContextLoader initWebApplicationContext
严重: Context initialization failed
java.lang.NoClassDefFoundError
org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
......
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
.......
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by: java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 30 more
2015-1-13 10:01:23 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
.....
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 30 more
2015-1-13 10:01:23 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2015-1-13 10:01:23 org.apache.catalina.core.StandardContext start
严重: Context [/SSH01] startup failed due to previous errors
2015-1-13 10:01:23 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2015-1-13 10:01:23 org.springframework.web.context.support.XmlWebApplicationContext doClose
信息: Closing Root WebApplicationContext: startup date [Tue Jan 13 10:01:22 CST 2015]; root of context hierarchy
2015-1-13 10:01:23 org.springframework.web.context.support.XmlWebApplicationContext doClose
警告: Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Tue Jan 13 10:01:22 CST 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:346)
............
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2015-1-13 10:01:23 org.springframework.web.context.support.XmlWebApplicationContext doClose
警告: Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Tue Jan 13 10:01:22 CST 2015]; root of context hierarchy
............
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2015-1-13 10:01:23 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2015-1-13 10:01:23 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2015-1-13 10:01:23 org.apache.catalina.startup.Catalina start
信息: Server startup in 2035 ms


从我的配置来看,没有看到问题。从错误上讲,说是缺少了aspectjweaver.jar这个包,但是我项目里面已经添加了spring-aspects-4.0.0.RELEASE.jar 。web.xml文件中也注册了Spring
其中文件代码
   <!-- 添加对spring的支持 -->  
  <context-param>  
    <param-name>contextConfigLocation</param-name>  
    <param-value>classpath:applicationContext.xml</param-value>  
  </context-param>  
    
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
    </listener> 

applicationContext.xml文件中的代码为
<?xml version="1.0" encoding="UTF-8"?>    
<beans xmlns="http://www.springframework.org/schema/beans"    
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
        xmlns:p="http://www.springframework.org/schema/p"  
        xmlns:aop="http://www.springframework.org/schema/aop"   
        xmlns:context="http://www.springframework.org/schema/context"  
        xmlns:jee="http://www.springframework.org/schema/jee"  
        xmlns:tx="http://www.springframework.org/schema/tx"  
        xsi:schemaLocation="    
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd  
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd  
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd  
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">    
      
       <!-- 加载数据库属性配置文件 -->  
       <context:property-placeholder location="classpath:db.properties" />  
       
       <!-- 配置c3p0数据源 -->
       <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
          <!-- 用户名-->  
          <property name="user" value="${username}"/>  
          <!-- 用户密码-->  
          <property name="password" value="${password}"/>  
          <property name="driverClass" value="${driver_class}"/>  
          <property name="jdbcUrl" value="${url}"/>  
     <property name="initialPoolSize" value="${initialPoolSize}"/>  
     <property name="maxPoolSize" value="${maxPoolSize}"/>
           
     </bean>  
     
       <!-- 配置sessionFactory -->  
     <bean id="sessionFactory"  
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">  
        <property name="dataSource">  
            <ref bean="dataSource" />  
        </property>  
        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>  
        <property name="mappingLocations" value="classpath:com/ssh/po/*.hbm.xml"/> 
        <!-- 自动扫描注解方式配置的hibernate类文件 -->  
        <property name="packagesToScan">  
            <list>  
                <value>com.bufoon.entity</value>  
            </list>  
        </property>  
    </bean>  

  <!-- 配置事务管理器 -->  
    <bean id="transactionManager"  
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">  
        <property name="sessionFactory" ref="sessionFactory" />  
    </bean>  
  
    <!-- 配置事务通知属性 -->  
    <tx:advice id="txAdvice" transaction-manager="transactionManager">  
        <!-- 定义事务传播属性 -->  
        <tx:attributes>  
            <tx:method name="insert*" propagation="REQUIRED" />  
            <tx:method name="update*" propagation="REQUIRED" />  
            <tx:method name="edit*" propagation="REQUIRED" />  
            <tx:method name="save*" propagation="REQUIRED" />  
            <tx:method name="add*" propagation="REQUIRED" />  
            <tx:method name="new*" propagation="REQUIRED" />  
            <tx:method name="set*" propagation="REQUIRED" />  
            <tx:method name="remove*" propagation="REQUIRED" />  
            <tx:method name="delete*" propagation="REQUIRED" />  
            <tx:method name="change*" propagation="REQUIRED" />  
            <tx:method name="get*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="find*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="load*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="*" propagation="REQUIRED" read-only="true" />  
        </tx:attributes>  
    </tx:advice>  
      
    <!-- 应用普通类获取bean    
    <bean id="appContext" class="com.soanl.util.tool.ApplicationUtil"/>-->  
  
    <!-- 配置事务切面 -->  
    <aop:config>  
        <aop:pointcut id="serviceOperation"  
            expression="execution(* com.ssh.service..*.*(..))" />  
        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />  
    </aop:config>  
  
    <!-- 自动加载构建bean -->  
    <context:component-scan base-package="com.bufoon" />  
  
</beans>  

------解决思路----------------------
Caused by: java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException 
你这没说你没有导入jar包。 是你的ja包里没有ReflectionWorld这个类。你看看你的jar包吧,不行就更换jar包
  相关解决方案