【问题标题】:org/apache/http/util/Args (java.lang.NoClassDefFoundError). Message payload is of type: Stringorg/apache/http/util/Args (java.lang.NoClassDefFoundError)。消息有效负载的类型:字符串
【发布时间】:2015-06-11 04:39:50
【问题描述】:

我的 mule 应用程序能够使用以下 maven 依赖项运行。

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.9.40</version>
    </dependency>

    <dependency> 
        <groupId>org.apache.httpcomponents</groupId> 
        <artifactId>httpcore</artifactId> 
        <version>4.4.1</version> 
    </dependency> 

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.4.1</version>
    </dependency>

它运行顺利,但是一旦我向它发送 POST,它就会生成“NoClassDefFoundError”


ERROR 2015-06-11 12:34:10,406 [[dynamodb-01].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : org/apache/http/util/Args (java.lang.NoClassDefFoundError). Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. org.apache.http.util.Args (java.lang.ClassNotFoundException)
  java.net.URLClassLoader$1:366 (null)
2. org/apache/http/util/Args (java.lang.NoClassDefFoundError)
  org.apache.http.conn.scheme.Scheme:90 (null)
3. org/apache/http/util/Args (java.lang.NoClassDefFoundError). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.ClassNotFoundException: org.apache.http.util.Args
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

【问题讨论】:

标签: java apache maven mule amazon-dynamodb


【解决方案1】:

您的错误表明您的应用程序在运行时缺少 jar httpcore.4.4.1 中的类。尝试为您正在导入的库提供运行时的依赖范围。

查看以下网址https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

<dependency> 
        <groupId>org.apache.httpcomponents</groupId> 
        <artifactId>httpcore</artifactId> 
        <version>4.4.1</version>
<scope>runtime</scope>
    </dependency> 

如果编译和运行时也需要 jar,请使用“provided”范围。

<dependency> 
        <groupId>org.apache.httpcomponents</groupId> 
        <artifactId>httpcore</artifactId> 
        <version>4.4.1</version>
<scope>provided</scope>
    </dependency>

请注意,maven 中的默认作用域(如果未指定)是 compile,其中库中的作用域将仅用于编译。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多