0

我正在尝试在 Wildfly 13 中部署使用 Webscoket 客户端作为消费者的 Camel Route。

当我尝试运行该项目时,出现以下错误:

Caused by: [java.lang.RuntimeException - Could not find an implementation class.]: java.lang.RuntimeException: Could not find an implementation class.
        at javax.websocket.ContainerProvider.getWebSocketContainerImpl(ContainerProvider.java:89)
        at javax.websocket.ContainerProvider.getWebSocketContainer(ContainerProvider.java:69)

我正在使用以下依赖项:

<dependency>
 <groupId>org.glassfish.tyrus.bundles</groupId>
 <artifactId>tyrus-standalone-client</artifactId>
 <version>1.15</version>
</dependency>

在 Eclipse 上运行代码,一切正常。

我需要在 Wildfly 或项目中做一些特定的配置来运行这段代码吗?

我的 Maven 构建:

<build>
  <resources>
    <resource>
      <filtering>true</filtering>
      <directory>src/main/resources</directory>
    </resource>
  </resources>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.7.0</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
      <version>3.1.0</version>
      <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <classpathLayoutType>custom</classpathLayoutType>
            <customClasspathLayout>META-INF</customClasspathLayout>
          </manifest>
        </archive>
      </configuration>
    </plugin>
  </plugins>
</build>
4

1 回答 1

1

从您的描述中很难看出您的特定设置有什么问题,但通常,在 WildFly 之上编写 Camel 集成的最简单方法是使用 WildFly Camel:https ://wildfly-extras.github.io/wildfly-camel /#_入门

通过 Undertow 组件支持 Websocket。对于如下所示的简单路线

from("undertow:ws://localhost:8080/my-app")
    .log("Message received from WebSocket Client : ${body}")

您只需要 undertow-component 依赖项(注意provided范围):

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.camel</groupId>
                <artifactId>wildfly-camel-bom</artifactId>
                <version><!-- your WF Camel version --></version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-undertow</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

免责声明:我是 WildFly Camel 的维护者之一

于 2019-05-07T13:12:14.870 回答