admin管理员组

文章数量:1392086

  • I recently upgraded from JBOSS 7.4 to JBOSS 8.0.
  • I'm currently testing this on Windows 11 and openjdk 17 but the behavior is the same on a linux distro
  • For some reason I cant get my application to do a JNDI lookup and write to the queue.
  • I keep getting the below error:
09:49:55,595 ERROR [stderr] (default task-1) javax.naming.NamingException: Failed to lookup [Root exception is java.lang.ClassNotFoundException: .apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl from [Module "deployment.TESTQUEUE.war" from Service Module Loader]]
09:49:55,596 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.util.NamingUtils.namingException(NamingUtils.java:171)
09:49:55,597 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.remote.RemoteClientTransport.lookup(RemoteClientTransport.java:291)
09:49:55,597 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.remote.RemoteContext.lambda$lookupNative$0(RemoteContext.java:190)
09:49:55,597 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.NamingProvider.performExceptionAction(NamingProvider.java:222)
09:49:55,597 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.remote.RemoteContext.performWithRetry(RemoteContext.java:100)
09:49:55,597 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.remote.RemoteContext.lookupNative(RemoteContext.java:188)
09:49:55,599 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:74)
09:49:55,599 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.store.RelativeFederatingContext.lookupNative(RelativeFederatingContext.java:58)
09:49:55,601 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:74)
09:49:55,602 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:60)
09:49:55,603 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:66)
09:49:55,603 ERROR [stderr] (default task-1)    at [email protected]//.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:144)
09:49:55,603 ERROR [stderr] (default task-1)    at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
09:49:55,604 ERROR [stderr] (default task-1)    at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
09:49:55,604 ERROR [stderr] (default task-1)    at deployment.TESTQUEUE.war//QueueWriter.writeToRequestQueue(QueueWriter.java:49)
09:49:55,605 ERROR [stderr] (default task-1)    at deployment.TESTQUEUE.war//NewServlet.processRequest(NewServlet.java:48)
09:49:55,605 ERROR [stderr] (default task-1)    at deployment.TESTQUEUE.war//NewServlet.doPost(NewServlet.java:79)
09:49:55,606 ERROR [stderr] (default task-1)    at [email protected]//jakarta.servlet.http.HttpServlet.service(HttpServlet.java:547)

  • It's failing on exactly this line trying to lookup the connection factory: connectionFactory = (ConnectionFactory) namingContext.lookup("jms/RemoteConnectionFactory");

  • Below is the code I'm writing to queue with:

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.HashMap;
import java.util.Properties;
import java.util.logging.Logger;


public class QueueWriter {
 Context namingContext = null;
    private ConnectionFactory connectionFactory;
 
    private Queue queue;
 
    private Connection connection;
 
    private Session session;
 
    private MessageProducer messageProducer;


    public QueueWriter() {
    }
    public boolean writeToRequestQueue(String queueName, HashMap dataMap) {
        boolean writeToQueue = false;
        String messageID = "1223334343535456";
       // messageID = (String) dataMap.get("CorrelationID");
        try {
            final Properties P = new Properties();
            P.put(Context.INITIAL_CONTEXT_FACTORY, ".wildfly.naming.client.WildFlyInitialContextFactory");
            P.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080");
            P.put(Context.SECURITY_PRINCIPAL, "queue");
            P.put(Context.SECURITY_CREDENTIALS, "Pass@123");
            namingContext = new InitialContext(P);
            connectionFactory = (ConnectionFactory) namingContext.lookup("jms/RemoteConnectionFactory");
            System.out.println("Attempting to acquire connection factory"+ connectionFactory);
             this.queue = (Queue) namingContext.lookup("jms/queue/ESBChannelRequest_Queue");
            //this.queue = (Queue) namingContext.lookup(queueName);
            connection = connectionFactory.createConnection("queue", "Pass@123"); // specify username and password
            connection.start();
          System.out.println("Attempting to acquire connection status>>>>>>"+ connection.getClientID());

            this.session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            this.messageProducer = session.createProducer((Destination) this.queue);
 
            TextMessage textMessage = session.createTextMessage();
            textMessage.setText("TEST MESSAGE"); // Set the request data in the message
            textMessage.setJMSCorrelationID(messageID); // Set the correlation ID
 
            this.messageProducer.send(textMessage);
 
            writeToQueue = true;
            releaseConnections();
        } catch (JMSException ex) {
          ex.printStackTrace();
        } catch (NamingException ex) {
            ex.printStackTrace();
        } finally {

        }
        return writeToQueue;
    }
    
    public void releaseConnections() {
        try {
            if (this.messageProducer != null) {
                this.messageProducer.close();
            }

            if (this.session != null) {
                this.session.close();
            }

            if (this.connection != null) {
                this.connection.close();
            }

            this.closeReleaseOtherResources();
        } catch (Exception var3) {
           var3.printStackTrace();
        }

    }

    private void closeReleaseOtherResources() {
        try {

            if (this.queue != null) {
                this.queue = null;
            }

            if (this.connectionFactory != null) {
                this.connectionFactory = null;
            }

            if (this.connectionFactory != null) {
                this.connectionFactory = null;
            }

            if (this.namingContext != null) {
                this.namingContext = null;
            }
        } catch (Exception var3) {
            var3.printStackTrace();
        }

    }
}
  • My messaging subsystem on standalone-full.xml:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:15.0">
            <server name="default">
                <security elytron-domain="ApplicationDomain"/>
                <statistics enabled="true"/>
                <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"/>
                <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">
                    <param name="buffer-pooling" value="false"/>
                </in-vm-connector>
                <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">
                    <param name="buffer-pooling" value="false"/>
                </in-vm-acceptor>
                <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
                <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
                <jms-queue name="ESBLogQueue" entries="java:jboss/exported/jms/queue/ESBLogQueue" durable="true"/>
                <jms-queue name="ESBCBSRequest_Q" entries="java:jboss/exported/jms/queue/ESBCBSRequest_Q" durable="true"/>
                <jms-queue name="ESBCBSResponse_Q" entries="java:jboss/exported/jms/queue/ESBCBSResponse_Q" durable="true"/>
                <jms-queue name="ESBChannelResponse_Queue" entries="java:jboss/exported/jms/queue/ESBChannelResponse_Queue" durable="true"/>
                <jms-queue name="ESBChannelRequest_Queue" entries="java:jboss/exported/jms/queue/ESBChannelRequest_Queue" durable="true"/>
                <jms-queue name="ESBBillerresponsequeue" entries="java:jboss/exported/jms/queue/ESBBillerresponsequeue" durable="true"/>
                <jms-queue name="ESBTICRequest_Q" entries="java:jboss/exported/jms/queue/ESBTICRequest_Q" durable="true"/>
                <jms-queue name="ESBTICResponse_Q" entries="java:jboss/exported/jms/queue/ESBTICResponse_Q" durable="true"/>
                <jms-queue name="ESBPortalAdaptorResponse_Queue" entries="java:jboss/exported/jms/queue/ESBAdminPortalAdaptorResponse_Queue" durable="true"/>
                <jms-queue name="ESBAccountOpeningResponseQueue" entries="java:jboss/exported/jms/queue/ESBAccountOpeningResponseQueue" durable="true"/>
                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm" factory-type="XA_GENERIC"/>
                <pooled-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>
  • I have tried to switch libraries from javax.jms* to jakarta.jms* but the error remains persistent

  • I have also tried multiple fresh installs and reinstalls of JBOSS 8.0 from the official site to no avail

本文标签: javaNamingException and ClassNotFoundException when attempting a JNDI lookup on Jboss 80Stack Overflow