MessageProducer not able to connect in wildfly9.0.0
htcprasad Jun 29, 2015 9:31 PMI deployed a mesageDriven Bean in wildfly9.0.0. but when i am trying to send an object message, i am getting an error
[java] error:javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://127.0.0.1:4447 (java.net.ConnectException: Connection refused: no further information)]
my MessageProducer is
package htc.mdb3;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueConnection;
import javax.jms.QueueSession;
import javax.jms.Queue;
import javax.jms.QueueSender;
import javax.jms.Session;
import javax.jms.Message;
import javax.jms.TopicPublisher;
import javax.jms.ObjectMessage;
import java.util.Properties;
public class HotProductCreator {
public static final String FACTORY_NAME =
"jms/RemoteConnectionFactory";
public static final String DEST_NAME = "jms/queue/test";
public static InitialContext getInitialContext() {
Properties props = new Properties();
InitialContext jndiCtx = null;
try {
props.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
jndiCtx = new InitialContext(props);
}catch(Exception ex) {}
return jndiCtx;
}
public static void main(String[] args) {
try {
Context ctx = getInitialContext();
QueueConnectionFactory factory =
(QueueConnectionFactory)ctx.lookup(FACTORY_NAME);
QueueConnection con = factory.createQueueConnection();
QueueSession session = con.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue)ctx.lookup(DEST_NAME);
QueueSender sender = session.createSender(queue);
ObjectMessage msg = session.createObjectMessage();
ProductDTO dto = new ProductDTO(1000,"SonyTV","A",23432.20);
msg.setObject(dto);
sender.send(msg);
System.out.println("Sent Message");
con.close();
}catch(Exception e){
System.out.println("error:"+e);
}
}
}
jboss-ejb-client.properties
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port = 8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=tester
remote.connection.default.password=testing9@
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
jndi.properties
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
java.naming.provider.url=remote://127.0.0.1:4447
java.naming.security.principal=tester
java.naming.security.credentials=testing9@
this has run well in JBOSS7.1.1
-
mdb3.zip 4.8 KB