java.lang.NoClassDefFoundError:ognl / PropertyAccessor

时间:2016-01-25 10:33:52

标签: struts2 ognl

我只是尝试在eclipse ide上编译一个简单的hello java程序。这是堆栈跟踪。我为struts 2添加了所有必需的库。

java.lang.NoClassDefFoundError: ognl/PropertyAccessor
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:342)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:235)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3800)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4450)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

2 个答案:

答案 0 :(得分:2)

<dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    <version>3.1.12</version> 
</dependency>

将此添加到pom文件中。在弹簧靴中使用百里香叶起动器时。

答案 1 :(得分:1)

您缺少Apache Commons OGNL框架库。您可以从Apache Commons OGNL page下载。

  

依赖树:

org.apache.commons:commons-ognl:jar:4.0-SNAPSHOT Information
    junit:junit:jar:4.10 (test) Information
        org.hamcrest:hamcrest-core:jar:1.1 (test) Information
    org.easymock:easymock:jar:2.3 (test) Information
    org.javassist:javassist:jar:3.16.1-GA (compile) Information
    com.carrotsearch:junit-benchmarks:jar:jdk15:0.3.0 (test) Information
    ognl:ognl:jar:3.0.2 (test) Information
        javassist:javassist:jar:3.11.0.GA (test) Information
    org.slf4j:slf4j-api:jar:1.6.1 (test) Information
    com.h2database:h2:jar:1.3.158 (test) Information