Hi Jaikiran,
You are right. At every subsequent request i got the exception. However, first exception occurs at:
ContextSelector < EJBClientContext > selector = new ConfigBasedEJBClientContextSelector(cc);
and i couldn't catch the exception. I must catch the exception, because i warn the user about entering wrong username/password or for other wrong things.
I surround the code with try/catch like this:
try {
Properties pr = new Properties();
pr.put("endpoint.name", "client-endpoint");
pr.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
pr.put("remote.connections", "default");
pr.put("remote.connection.default.port", "4447");
pr.put("remote.connection.default.host", "localhost");
pr.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
pr.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
pr.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
pr.put("remote.connection.default.username", "user1");
pr.put("remote.connection.default.password", "Test12345");
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(pr);
ContextSelector < EJBClientContext > selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
}
catch (Exception ex) {
// log ex
}
Exception occurs, but i couldn't catch it. I think it is catched in the api and logged there. Log is like below:
log4j:ERROR Could not find value for key log4j.appender.file
log4j:ERROR Could not instantiate appender named "file".
07.05.2012 08:50:05: DEBUG logging [main] - Logging Provider: org.jboss.logging.Log4jLoggerProvider
07.05.2012 08:50:05: DEBUG PropertiesBasedEJBClientConfiguration [main] - endpoint.create.options. has the following options {}
07.05.2012 08:50:05: DEBUG PropertiesBasedEJBClientConfiguration [main] - remote.connectionprovider.create.options. has the following options {org.xnio.Options.SSL_ENABLED=>false}
07.05.2012 08:50:05: DEBUG PropertiesBasedEJBClientConfiguration [main] - remote.connection.default.connect.options. has the following options {org.xnio.Options.SASL_DISALLOWED_MECHANISMS=>[JBOSS-LOCAL-USER],org.xnio.Options.SASL_POLICY_NOPLAINTEXT=>false,org.xnio.Options.SASL_POLICY_NOANONYMOUS=>false}
07.05.2012 08:50:05: DEBUG PropertiesBasedEJBClientConfiguration [main] - remote.connection.default.channel.options. has the following options {}
07.05.2012 08:50:05: DEBUG PropertiesBasedEJBClientConfiguration [main] - Connection org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration$RemotingConnectionConfigurationImpl@18a992f successfully created for connection named default
07.05.2012 08:50:05: DEBUG PropertiesBasedEJBClientConfiguration [main] - No clusters configured in properties
07.05.2012 08:50:05: DEBUG EJBClientPropertiesLoader [main] - Looking for jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@d9f9c3
07.05.2012 08:50:05: DEBUG ConfigBasedEJBClientContextSelector [main] - EJB client context org.jboss.ejb.client.EJBClientContext@111a3ac will have no EJB receivers associated with it since there was no EJB client configuration available to create the receivers
07.05.2012 08:50:05: INFO xnio [main] - XNIO Version 3.0.3.GA
07.05.2012 08:50:05: INFO nio [main] - XNIO NIO Implementation Version 3.0.3.GA
07.05.2012 08:50:05: INFO remoting [main] - JBoss Remoting version 3.2.3.GA
07.05.2012 08:50:05: DEBUG nio [Remoting "client-endpoint" read-1] - Started channel thread 'Remoting "client-endpoint" read-1', selector sun.nio.ch.WindowsSelectorImpl@16672d6
07.05.2012 08:50:05: DEBUG nio [Remoting "client-endpoint" write-1] - Started channel thread 'Remoting "client-endpoint" write-1', selector sun.nio.ch.WindowsSelectorImpl@fd54d6
07.05.2012 08:50:12: DEBUG client [Remoting "client-endpoint" read-1] - Client received authentication rejected for mechanism PLAIN
07.05.2012 08:50:12: ERROR connection [Remoting "client-endpoint" read-1] - JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
07.05.2012 08:50:12: WARN ConfigBasedEJBClientContextSelector [main] - Could not register a EJB receiver for connection to remote://localhost:4447
java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:91)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:121)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.<init>(ConfigBasedEJBClientContextSelector.java:78)
at tr.gov.tubitak.bilgem.uekae.deys.tckk.kuvars.KuvarsEjbTestAS7.<init>(KuvarsEjbTestAS7.java:109)
at tr.gov.tubitak.bilgem.uekae.deys.tckk.kuvars.KuvarsEjbTestAS7.main(KuvarsEjbTestAS7.java:430)
Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:315)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)
at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
at org.xnio.nio.NioHandle.run(NioHandle.java:90)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)
at ...asynchronous invocation...(Unknown Source)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:119)
... 3 more
07.05.2012 08:50:12: DEBUG ConfigBasedEJBClientContextSelector [main] - Registered a reconnect handler in EJB client context org.jboss.ejb.client.EJBClientContext@b61fd1 for remote://localhost:4447
07.05.2012 08:50:12: DEBUG ConfigBasedEJBClientContextSelector [main] - Registered 0 remoting EJB receivers for EJB client context org.jboss.ejb.client.EJBClientContext@b61fd1
07.05.2012 08:50:12: INFO client [main] - JBoss EJB Client version 1.0.5.Final
07.05.2012 08:50:12: DEBUG AutoConnectionCloser [Thread-1] - Closing endpoint "client-endpoint" <e91f5d>
Could you please explain how i could catch the exception? Thanks...