apache-camel - Wildfly-Camel 12 中的 Groovy JsonBuilder 类加载错误

标签 apache-camel jboss7.x wildfly-12

我在 Camel 路由内的 Groovy 代码中调用 JsonBuilder.toString() 。这条 Camel 路线在 Widflly Camel 12.0 内运行。代码如下所示:

def builder = new JsonBuilder()
builder {
'myField': myFieldVal
}
return builder.toString()

builder.toString() 方法调用会产生以下错误:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
groovy.json.internal.FastStringUtils

但是我确实在 pom.xml 中正确提到了依赖项,如下所示:

<dependency>
 <groupId>org.apache.camel</groupId>
 <artifactId>camel-groovy</artifactId>
 <scope>provided</scope>
</dependency>

我还尝试添加这个额外的依赖项来解决问题:

<dependency>
 <groupId>org.codehaus.groovy</groupId>
 <artifactId>groovy-json</artifactId>       
 <version>2.4.13</version>
</dependency>

但我仍然不断收到上述异常。然而,当我使用camel-maven-plugin运行相同的Camel代码,而不将其部署在Wildfly中时,它运行得很好。

有人可以帮忙吗?

提前致谢。

最佳答案

我认为问题是模块org.apache.camel.script.groovy无法访问sun.misc.Unsafe。因此,我将以下模块依赖项添加到 modules/system/layers/fuse/org/apache/camel/script/groovy/main/module.xml

<module name="sun.jdk">
  <imports>
    <include path="sun/misc/Unsafe"/>
  </imports>
</module>

你的例子后来对我有用。

关于apache-camel - Wildfly-Camel 12 中的 Groovy JsonBuilder 类加载错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50459736/

相关文章:

java - Camel 代理提示类型错误

java - 在 Apache Camel 中输出 CSV 列标题

load-balancing - Keycloak invalid_token 没有找到指定 child 的公钥

caching - Wildfly infinispan Web 缓存容器的用途是什么?

java - 如何从另一台计算机访问 WildFly 12 服务器上的 Web 应用程序?

logging - 如何在 Camel 的 onException 子句中设置记录器(日志类别/日志名称)?

java - 从camel属性占位符填充java.util.Properties

java - EJB 3.1 - 为什么无状态 bean 必须通过其接口(interface)注入(inject)(如果有的话)?

java - JBoss AS 7.1 JBREM000200 : Remote connection failed: java. io.IOException:已建立的连接被主机中的软件中止

java - 即使没有事务,在 jboss 中检索到多个数据库的连接时出错