Remote connection failed - Authentication failed: all available authentication mechanisms failed
lauradp Nov 9, 2012 4:34 AMHello everybody,
I implemented this queue writer:
package writer;
import java.io.IOException;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* @author Laura delli Paoli
*
*/
public class QueueWriter {
private final static String JMS_FACTORY="jms/RemoteConnectionFactory";
private ConnectionFactory conFactory;
private Connection con;
private Session session;
private static MessageProducer producer;
private Destination destination;
private static TextMessage msg;
private String username = null, password = null;
public QueueWriter(String username, String password, Context ctx, String destName) throws NamingException, JMSException {
super();
this.username = username;
this.password = password;
init(ctx, destName);
}
private void init(Context ctx, String destName)throws NamingException, JMSException {
conFactory = (ConnectionFactory) ctx.lookup(JMS_FACTORY);
//*************** Creating Queue Connection using the UserName & Password *************************
con = conFactory.createConnection(username, password);
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = (Destination) ctx.lookup("jms/"+destName);
producer = session.createProducer(destination);
msg = session.createTextMessage();
con.start();
}
public void sendTextMsg(String mess) throws IOException, JMSException {
System.out.println("Generic Sender"+"\n"+"Following Messages has been sent !!!");
String [] colors = {"BLUE", "RED", "BLUE"};
for(int j=1;j<=3;j++) {
msg.setText("Message #" + j + ": "+mess); // Messages
msg.setStringProperty("color", colors[j-1]);
producer.send(msg); // Messages sent
System.out.println("Message ("+colors[j-1]+") sent = "+j +": " + msg.getText());
}
}
public static InitialContext getInitialContext(String PROVIDER_URL, String username, String password) {
/*Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put("jboss.naming.client.ejb.context", true);*/
Context remoteContext = null;
try {
//remoteContext = new InitialContext(env);
remoteContext = new InitialContext();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (InitialContext) remoteContext;
}
public void close () throws JMSException {
if (producer != null) producer.close();
if (session != null) session.close();
if (con != null) con.close();
}
}
when I tryed to run in with the folllowing main:
/**
*
*/
package writer;
import java.io.IOException;
import javax.jms.JMSException;
//import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* @author Laura delli Paoli
*
*/
public class runWriter {
private static final String DEFAULT_USERNAME = "pippo";
private static final String DEFAULT_PASSWORD = "pluto";
private static final String PROVIDER_URL = "remote://localhost:4447";
public final static String QUEUE_NAME="queue/TestQ";
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
InitialContext ctx = QueueWriter.getInitialContext(PROVIDER_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
QueueWriter writer = null;
try {
if (ctx != null) writer = new QueueWriter(DEFAULT_USERNAME, DEFAULT_PASSWORD, ctx, QUEUE_NAME);
else System.out.println("Undefined initial context");
writer.sendTextMsg("Hello from Laura!");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer != null)
try {
writer.close();
} catch (JMSException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (ctx != null)
try {
ctx.close();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
I got the following excepiton:
9-nov-2012 9.57.19 org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
9-nov-2012 9.57.22 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
9-nov-2012 9.57.24 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
9-nov-2012 9.57.40 org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at writer.QueueWriter.getInitialContext(QueueWriter.java:73)
at writer.runWriter.main(runWriter.java:29)
Caused by: java.lang.RuntimeException: Operation failed with status WAITING
at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)
at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
... 6 more
Undefined initial context
Can anyone help me?
-
writer.log.zip 734 bytes
-
server.log.zip 11.4 KB
-
jndi.properties.zip 787 bytes
-
jboss-ejb-client.properties.zip 487 bytes
-
standalone-jbpm-Laura.xml 28.9 KB