有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Wildfly 10 JMS:EmailDispatchMDB$$$endpoint2无法转换为javax。资源spi。终点。消息端点

我正在将当前运行在Jboss 6.1.0上的一个旧应用程序迁移到wildfly 10.1.0

我已经创建了从旧应用程序到独立完整的默认配置的所有队列。但在服务器启动时,我遇到了一个问题“不能转换为javax.resource.spi.endpoint.MessageEndpoint”。 我还添加了引发此错误的代码段

知道我做错了什么吗

单机版已满。xml

...
...

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
            <server name="default">
                <security-setting name="#">
                    <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
                </security-setting>
                <address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
                <address-setting name="jms.queue.InboundNotificationResponseQueue" dead-letter-address="jms.queue.bblDeadLetterQueue" expiry-address="jms.queue.bblExpiryQueue"/>
                <address-setting name="jms.queue.EventDispatchQueue" dead-letter-address="jms.queue.bblDeadLetterQueue" expiry-address="jms.queue.bblExpiryQueue"/>
                <address-setting name="jms.queue.OutboundEmailQueue" dead-letter-address="jms.queue.bblDeadLetterQueue" expiry-address="jms.queue.bblExpiryQueue"/>

                <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
                <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
                    <param name="batch-delay" value="50"/>
                </http-connector>
                <in-vm-connector name="in-vm" server-id="0"/>
                <http-acceptor name="http-acceptor" http-listener="default"/>
                <http-acceptor name="http-acceptor-throughput" http-listener="default">
                    <param name="batch-delay" value="50"/>
                    <param name="direct-deliver" value="false"/>
                </http-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0"/>
                <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
                <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
                <jms-queue name="bblDeadLetterQueue" entries="java:/bbl/bblDeadLetterQueue"/>
                <jms-queue name="OutboundEmailQueue" entries="java:/bbl/OutboundEmailQueue"/>
                <jms-queue name="InboundNotificationResponseQueue" entries="java:/bbl/InboundNotificationResponseQueue"/>

                <jms-queue name="EventDispatchQueue" entries="java:/bbl/EventDispatchQueue"/>
                <jms-queue name="bblExpiryQueue" entries="java:/bbl/bblExpiryQueue"/>
                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
                <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
                <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
            </server>
        </subsystem>
...
...

代码:EmailDispatchMDB。爪哇

package com.mcg.bbl.email.dispatcher;
import java.util.Arrays;
import java.util.List;


import javax.annotation.Resource;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.MessageDriven;
import javax.ejb.MessageDrivenContext;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;


import org.apache.commons.lang.time.StopWatch;
import org.apache.log4j.Logger;


@MessageDriven(name = "EmailDispatchMDB", activationConfig = {
  @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
  @ActivationConfigProperty(propertyName="destination", propertyValue="java:/bbl/OutboundEmailQueue")
})

public class EmailDispatchMDB implements MessageListener {

  private static final Logger LOG = Logger.getLogger(EmailDispatchMDB.class); 

    @Resource
    private MessageDrivenContext context;


    @EJB(mappedName="bbl-server/NotificationService/remote")
    private NotificationService notificationService;


  public EmailDispatchMDB(){
  }

  public void finalize() throws Throwable {
  }

  @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void onMessage( Message message ) {
  /* Custom Code */
  }
  }

日志语句:

17:09:21,506 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=D:\projects\MCG\Software\wildfly-10.1.0.Final\standalone\data\activemq\journal,bindingsDirectory=D:\projects\MCG\Software\wildfly-10.1.0.Final\standalone\data\activemq\bindings,largeMessagesDirectory=D:\projects\MCG\Software\wildfly-10.1.0.Final\standalone\data\activemq\largemessages,pagingDirectory=D:\projects\MCG\Software\wildfly-10.1.0.Final\standalone\data\activemq\paging)

...

17:09:28,604 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.1.0.wildfly-017 [nodeID=a3b04b10-d656-11e6-8bd3-c391bfc23687]

...

17:09:28,888 INFO [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 72) WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory 17:09:28,898 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 73) AMQ221003: trying to deploy queue jms.queue.OutboundEmailQueue

...

17:09:49,857 INFO [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0042: Started message driven bean 'EmailDispatchMDB' with 'activemq-ra.rar' resource adapter

...

17:09:56,420 WARN [org.apache.activemq.artemis.ra] (default-threads - 5) AMQ152005: Failure in broker activation org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.apache.activemq.artemis.ra.ActiveMQResourceAdapter@78712571 destination=java:/bbl/OutboundEmailQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.ClassCastException: com.MCG.bbl.email.dispatcher.EmailDispatchMDB$$$endpoint2 cannot be cast to javax.resource.spi.endpoint.MessageEndpoint at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:75) at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:63) at org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.setup(ActiveMQMessageHandler.java:187) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.setup(ActiveMQActivation.java:318) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation$SetupActivation.run(ActiveMQActivation.java:719) at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:223) at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:808) at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:828) at java.lang.Thread.run(Thread.java:744) at org.jboss.threads.JBossThread.run(JBossThread.java:320)

...

17:09:58,488 INFO [org.apache.activemq.artemis.ra] (default-threads - 5) AMQ151001: Attempting to reconnect org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.apache.activemq.artemis.ra.ActiveMQResourceAdapter@78712571 destination=java:/bbl/OutboundEmailQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)

...

17:09:58,693 ERROR [org.apache.activemq.artemis.ra] (default-threads - 5) AMQ154003: Unable to reconnect org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.apache.activemq.artemis.ra.ActiveMQResourceAdapter@78712571 destination=java:/bbl/OutboundEmailQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.ClassCastException: com.mcg.bbl.email.dispatcher.EmailDispatchMDB$$$endpoint2 cannot be cast to javax.resource.spi.endpoint.MessageEndpoint at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:75) at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:63) at org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.setup(ActiveMQMessageHandler.java:187) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.setup(ActiveMQActivation.java:318) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.reconnect(ActiveMQActivation.java:678) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation$SetupActivation.run(ActiveMQActivation.java:722) at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:223) at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:808) at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:828) at java.lang.Thread.run(Thread.java:744) at org.jboss.threads.JBossThread.run(JBossThread.java:320)


共 (1) 个答案

  1. # 1 楼答案

    这个问题解决了,它是jar相关的问题。由于我正在从JBoss6升级到wildfly 10,所以该项目不知何故引用了jboss 6特有的jar“jboss-connector-api_1.5_spec-1.0.0.Final.jar”。我纠正了这个依赖关系,并配置了正确的模块“javax.resource.api”,它有最新的jar“jboss-connector-api_1.7_spec-1.0.Final.jar”,错误得到了解决

    所以得出的结论是,该项目引用的是jar的旧版本,需要进行更正

    希望这有帮助