当前位置: 首页 > 知识库问答 >
问题:

Wildfly-Swarm和通过资源适配器连接到外部activemq:WFLYCTL0412

斜高翰
2023-03-14
# Disable the artemis messaging completely
/subsystem=messaging-activemq/server=default:remove

# Deploy the resource adapter
deploy ${project.build.directory}/activemq-rar-5.15.0.rar

/subsystem=resource-adapters/resource-adapter=activemq-rar.rar:add(archive=activemq-rar-5.15.0.rar,transaction-support=LocalTransaction)
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/config-properties=ServerUrl:add(value="${activemq.broker}")
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/config-properties=UserName:add(value="${jboss.user}")
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/config-properties=Password:add(value="${jboss.password}")
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/config-properties=UseInboundSession:add(value="false")
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/connection-definitions=AMQConnectionFactory:add(jndi-name=ConnectionFactory,class-name=org.apache.activemq.ra.ActiveMQManagedConnectionFactory,enabled=true,min-pool-size=1,max-pool-size=20,pool-prefill=false,same-rm-override=false,use-java-context=true)
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/admin-objects=REQUESTQUEUE:add(class-name=org.apache.activemq.command.ActiveMQQueue,jndi-name=queues/request,use-java-context=true)
/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/admin-objects=REPLYQUEUE:add(class-name=org.apache.activemq.command.ActiveMQQueue,jndi-name=queues/reply,use-java-context=true)
/subsystem=ejb3:write-attribute(name=default-resource-adapter-name,value=activemq-rar.rar)
/subsystem=ejb3:write-attribute(name=default-mdb-instance-pool,value=mdb-strict-max-pool)
/subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory,value=java:/ConnectionFactory)

reload
"WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.activemq-rar"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"mdbtest.jar\".component.TestMDB.CREATE is missing [jboss.ra.activemq-rar]"]

为了设置群容器,我使用以下project-defaults.xml:

swarm:

  resource-adapters:
    resource-adapters:
      activemq-rar:
        archive: activemq-rar-15.5.0.rar
        transaction-support: LocalTransaction
        config-properties:
          ServerUrl:
            value: failover:tcp://localhost:61616
          UserName:
            value: admin
          Password:
            value: admin
          UseInboundSession:
            value: false

        connection-definitions:
            AMQConnectionFactory:
                jndi-name: ConnectionFactory
                class-name: org.apache.activemq.ra.ActiveMQManagedConnectionFactory
                enabled: true
                min-pool-size: 1
                max-pool-size: 20
                pool-prefill: false
                same-rm-override: false
                use-java-context: true
                same-rm-override: false

        admin-objects:
            REQUESTQUEUE:
                class-name: org.apache.activemq.command.ActiveMQQueue
                jndi-name: queues/request
                use-java-context: true
            REPLEYQUEUE:
                class-name: org.apache.activemq.command.ActiveMQQueue
                jndi-name: queues/reply
                use-java-context: true

  ejb3:
    # Switch the MDB default to the resource adapter defined above
    default-resource-adapter-name: activemq-rar
    default-mdb-instance-pool: mdb-strict-max-pool

  ee:
      default-bindings:
          jms-connection-factory: java:/ConnectionFactory


  management:
    security-realms:
      ManagementRealm:
        in-memory-authentication:
          users:
            admin:    
              password: admin                            
    http-interface-management-interface:
      allowed-origins:
      - http://localhost:8080
      security-realm: ManagementRealm

  messaging-activemq:
    servers:
      default:
#        active: false
#        connection-factories:
#          InVmConnectionFactory:
#            client-id: blahblabla
#            block-on-acknowledge: true
#            entries:
#            - "java:/ArtemisConnectionFactory"
#        pooled-connection-factories:
#          activemq-ra:
#            entries:
#            connectors: in-vm
#            transaction: xa

  jca:
    archive-validation:
      enabled: false


  datasources:
    jdbc-drivers:
      org.postgresql:
        driver-class-name: org.postgresql.Driver
        xa-datasource-class-name: org.postgresql.xa.PGXADataSource
        driver-module-name: org.postgresql

    data-sources:
      myDS:
        connection-url: jdbc:postgresql://localhost:5432/mydb
        user-name: dbuser
        password: dbpassword
        driver-name: postgresql
        jndi-name: java:jboss/datasources/myDS
        min-pool-size: 4
        max-pool-size: 64
        use-ccm: false


  deployment:
    org.apache.activemq:activemq-rar.rar:
    com.oneworldsync.mdb:mdbtest.jar:
    org.postgresql:postgresql.jar:

  logging:
    loggers:
      org.jboss:
        level: warn
      org.wildfly:
        level: warn

pom的相关部分如下所示:

<build>
  <plugins>
    <plugin>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>wildfly-swarm-plugin</artifactId> 
      <version>2017.4.0</version>
      <executions>
        <execution>
          <id>package</id>
          <goals>
            <goal>package</goal>
          </goals>
          <phase>package</phase>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>


<dependencies>
  <dependency>
    <groupId>com.oneworldsync.mdb</groupId>
    <artifactId>mdbtest</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>logging</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>datasources</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>undertow</artifactId>
  </dependency>
  <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.1.4</version>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>cdi</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>jpa</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>msc</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>infinispan</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>messaging</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>jca</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>resource-adapters</artifactId>
  </dependency>
  <dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-rar</artifactId>
    <version>${activemq.version}</version>
    <type>rar</type>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>management</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>management-console</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>cli</artifactId>
    <version>${jboss.version}</version>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>ejb</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>connector</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>jaxrs</artifactId>
  </dependency>
  <dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>remoting</artifactId>
  </dependency>
</dependencies>

测试MDB非常简单:

@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "acknowledgeMode",
            propertyValue = "Auto-acknowledge"),
    @ActivationConfigProperty(propertyName = "destination",
            propertyValue = "request"),
    @ActivationConfigProperty(propertyName = "destinationType",
            propertyValue = "javax.jms.Queue")
})
public class TestMDB implements MessageListener {

    @Resource(name = "java:/ConnectionFactory")
    private QueueConnectionFactory queueConnectionFactory;


    @Override
    public void onMessage(Message message) {
        System.out.println(message);
    }
}
2017-10-26 09:21:07,731 ERROR [stderr] (main) Caused by: java.lang.RuntimeException: org.wildfly.swarm.container.DeploymentException: org.wildfly.swarm.container.DeploymentException: WFSWARM0004: Deployment failed: {"WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.activemq-rar"],"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"mdbtest.jar\".component.TestMDB.CREATE is missing [jboss.ra.activemq-rar]"]}
2017-10-26 09:21:07,732 ERROR [stderr] (main)   at org.wildfly.swarm.spi.api.ClassLoading.withTCCL(ClassLoading.java:45)
2017-10-26 09:21:07,732 ERROR [stderr] (main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.bootstrap(ServerBootstrapImpl.java:114)
2017-10-26 09:21:07,732 ERROR [stderr] (main)   at org.wildfly.swarm.Swarm.start(Swarm.java:386)
2017-10-26 09:21:07,732 ERROR [stderr] (main)   at org.wildfly.swarm.Swarm.main(Swarm.java:720)
2017-10-26 09:21:07,732 ERROR [stderr] (main)   ... 6 more
    null

但是,基本原因是相同的(未找到依赖项)。我的解释是,maven插件在调用中添加了一个额外的层,该层记录额外的stacktrace,但问题仍然是一样的。

共有1个答案

宗政才俊
2023-03-14

最后,经过几个小时,我自己解决了这个问题。不出所料,解决方案简单但不明显...

我从这里得到的一个重要提示。经过一些认真的分析和调试,我发现资源适配器没有正确部署:虽然安装的服务中提到了合适的部署单元(JMX控制台非常有助于查找这些单元),但资源适配器本身仍然不可用。所有这些问题的解决方案是部署的名称:要正确部署适配器,必须使用以下代码片段:

swarm:
  deployment:
    org.apache.activemq:activemq-rar.rar:

请注意,必须省略maven版本号,只使用maven artifactId(与上面的原始代码片段相比)。由于swarm插件与maven依赖项管理紧密耦合,所以它自己计算物理名称。在一个独立的wildfly中,这是不同的:它不知道任何关于maven工件的信息,所以必须使用物理归档名。在standonal-full.xml中,如下所示:

<deployments>
   <deployment name="activemq-rar-5.15.0.rar" runtime-name="activemq-rar-5.15.0.rar">
       ...
swarm:
  deployment:
    org.apache.activemq:activemq-rar.rar:

  resource-adapters:
    resource-adapters:
      activemq-rar:
        # This is not the physical jar name, but the maven coordinates (without version!)
        archive: activemq-rar.rar
        transaction-support: LocalTransaction
        config-properties:
          ServerUrl:
            value: failover:tcp://localhost:61616
          UserName:
            value: admin
          Password:
            value: admin
          UseInboundSession:
            value: false

        connection-definitions:
            AMQConnectionFactory:
                jndi-name: ConnectionFactory
                class-name: org.apache.activemq.ra.ActiveMQManagedConnectionFactory
                enabled: true
                min-pool-size: 1
                max-pool-size: 20
                pool-prefill: false
                same-rm-override: false
                use-java-context: true

        admin-objects:
            REQUESTQUEUE:
                class-name: org.apache.activemq.command.ActiveMQQueue
                jndi-name: queues/request
                use-java-context: true
                config-properties:
                  PhysicalName: demo.request


  ejb3:
    default-resource-adapter-name: activemq-rar.rar
    default-mdb-instance-pool: mdb-strict-max-pool

  ee:
      default-bindings:
          jms-connection-factory: java:/ConnectionFactory


  management:
    security-realms:
      ManagementRealm:
        in-memory-authentication:
          users:
            admin:    
              password: admin                            
    http-interface-management-interface:
      allowed-origins: http://localhost:8080
      security-realm: ManagementRealm
      console-enabled: true

  messaging-activemq:
    servers:
      default:
        active: false
        connection-factories:
          InVmConnectionFactory:
            block-on-acknowledge: true
            entries:
            - "java:/ArtemisConnectionFactory"

  jca:
    archive-validation:
      enabled: false

  logging:
    loggers:
      org.jboss:
        level: INFO
      org.wildfly:
        level: INFO
 类似资料:
  • 我试图从Wildfly9连接到Websphere MQ,为此我添加了一个独立的资源适配器-full.xml 我已经添加了配置属性并删除了它们添加了不同的属性,这些属性看起来可能很有用,比如use-java-context=“true”pool-name=“jmsConnectionFactory”use-ccm=“true”删除了它们或使它们为false,更改了jndi名称,但它一直给我相同的结果

  • 我想试试wildfly swarm。我用Jax-rs-fraction和一个简单的hello-world资源创建了一个项目。我查过了,但找不到404。 这是我的pom。xml 这是我的Jax rs资源 如您所见,这非常简单。也许我错过了什么。我没有添加@Application ationPath注释类,因为根据留档(https://wildfly-swarm.gitbooks.io/wildfly

  • Generators 相关文章 The Basics Of ES6 Generators By Kyle Simpson ES6 generators in depth By Axel Rauschmayer redux-saga 相关文章 Redux nowadays : From actions creators to sagas By Riad Benguella Managing Side

  • 全局配置 在 nuxt.config.js 中配置你想引用的资源文件: module.exports = { head: { script: [ { src: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js' } ], link: [ { rel: 'style

  • 我使用postgres、wildfly-swarm、hibernate,我的事务是bean管理的。 my Project-defaults.yml datasources:data-sources:part 在模拟应用程序和postgres之间的连接丢失(关闭DB、iptables丢弃数据包等,然后执行一些请求,然后再次启动DB或清除iptables丢弃规则)后,DB已启动,但Hibernate/

  • 目前,我面临一些奇怪的行为。我有一个Java的EE Web应用程序,我正在部署到一个野蝇服务器。这个JavaEE应用程序需要一个数据库,我们需要通过vpn连接到该数据库。我们使用OpenVPN。当我使用SSMS时,我连接到数据库没有问题。当我使用纯JDBC时,也没有问题。 但是,如果我在wildfly中创建数据源(并且我使用的是完全相同的jdbc连接url),那么它就不起作用。我正在使用wildf