NoClassDefFoundError:org / apache / commons / configuration / ConfigurationException

时间:2013-04-03 12:50:40

标签: java maven apache-commons apache-commons-config

我有一个应用程序,我需要解析配置文件,当在服务器上运行此程序时,它提供以下跟踪:

java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException
    at com.messagedna.server.startup.StartupServlet.init(StartupServlet.java:19)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1274)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5033)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5320)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1553)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:622)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:569)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1419)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.ConfigurationException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 48 more
在我的类路径中,

apache commons 存在。它是。然而,我有这样的问题。

在firefox中的firebug中我在tomcat日志中看到以下跟踪:

<b>exception</b> <pre>java.lang.NoClassDefFoundError: com/google/gwt/user/client/rpc/RemoteService
    java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904)
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904)
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:461)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    java.lang.Thread.run(Thread.java:722)

实际上我并不害羞这两个例外有相同的原因。 如果有人能告诉我解决这些问题的方法,我将非常感激

UPD:这是我的pom.xml文件:

  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>DLP</artifactId>
        <groupId>com.messagedna.dlp</groupId>
        <version>1.0</version>
    </parent>
  <groupId>com.messagedna.dlp</groupId>
  <artifactId>DLPServer</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>DLPServer</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
      <dependency>
          <groupId>com.google.gwt</groupId>
          <artifactId>gwt-servlet</artifactId>
          <version>2.0.3</version>
      </dependency>
      <dependency>
          <groupId>com.google.gwt</groupId>
          <artifactId>gwt-user</artifactId>
          <version>2.0.3</version>
      </dependency>
      <dependency>
          <groupId>com.extjs</groupId>
          <artifactId>gxt</artifactId>
          <version>2.2.0</version>
      </dependency>
      <dependency>
          <groupId>commons-configuration</groupId>
          <artifactId>commons-configuration</artifactId>
          <version>1.9</version>
      </dependency>
      <dependency>
          <groupId>javax.mail</groupId>
          <artifactId>mail</artifactId>
          <version>1.4.5</version>
      </dependency>
      <dependency>
          <groupId>org.apache.james</groupId>
          <artifactId>apache-mime4j</artifactId>
          <version>0.6.1</version>
      </dependency>
      <dependency>
          <groupId>org.apache.tika</groupId>
          <artifactId>tika-parsers</artifactId>
          <version>1.2</version>
      </dependency>
      <dependency>
          <groupId>net.freeutils.jtnef</groupId>
          <artifactId>tnef</artifactId>
          <version>1.5.0</version>
      </dependency>
      <dependency>
          <groupId>com.messagedna-archive.mimeparser</groupId>
          <artifactId>MimeParser</artifactId>
          <version>1.0</version>
      </dependency>

      <dependency>
          <groupId>com.rabbitmq</groupId>
          <artifactId>amqp-client</artifactId>
          <version>3.0.4</version>
      </dependency>
      <dependency>
          <groupId>commons-lang</groupId>
          <artifactId>commons-lang</artifactId>
          <version>2.3</version>
      </dependency>
      <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jaxrs</artifactId>
          <version>2.3.4.Final</version>
      </dependency>
      <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jaxb-provider</artifactId>
          <version>2.3.4.Final</version>
      </dependency>

      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.10</version>
          <scope>test</scope>
      </dependency>
  </dependencies>
  <build>
        <outputDirectory>war/WEB-INF/classes</outputDirectory>
        <plugins>
              <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>gwt-maven-plugin</artifactId>
                  <version>1.2</version>
                  <executions>
                      <execution>
                          <goals>
                              <goal>compile</goal>
                              <goal>generateAsync</goal>
                              <goal>test</goal>
                          </goals>
                      </execution>
                  </executions>
                  <configuration>
                      <runTarget>Main.html</runTarget>
                      <style>OBFUSCATED</style>
                      <extraJvmArgs>-Xmx1024m -Xss1024k</extraJvmArgs>
                      <webappDirectory>war</webappDirectory>
                  </configuration>
              </plugin>

              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-war-plugin</artifactId>
                  <version>2.1.1</version>
                  <configuration>
                      <webappDirectory>war</webappDirectory>
                      <warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
                  </configuration>
              </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
  </build>
</project>

5 个答案:

答案 0 :(得分:2)

检查您的应用程序的lib文件夹中是否包含lib,您可能通过ant或maven通过打包将其保留。下一个可能的原因可能是你的jar被破坏了。尝试反编译和检查(虽然这是非常罕见的)。

总是记得classNotFound异常只是意味着你的程序无论出于何种原因都无法找到关注类。将它添加到lib / classpath中。没有其他可能的原因。

答案 1 :(得分:2)

想法中的问题(我使用intellij Idea)属性。他们因某种原因被打破了。我没有发现什么是错误的(运行配置的东西)并删除了所有想法文件,创建了一个新项目并将我的模块导入到我的程序开始工作的项目中。

答案 2 :(得分:0)

你的道路上还有Commons Lang吗?如果没有,Eclipse将无法解析ConfigurationException类,您将收到该错误。

答案 3 :(得分:0)

我在Glassfish运行时环境3.1.2的另一个实例上运行应用程序,它的工作原理!我当时正在使用3.1.2.2

可能是损坏的glassfish服务器实例或glassfish服务器3.1.2.2中的错误。

答案 4 :(得分:0)

哦,真的,JetBrains IDE有问题。使缓存无效并重新启动对我有帮助。