How to pass a Parameterized CallbackHandler to EJBClientContext properties in EAP6
Issue
- Is there a way to use a Custom CallbackHandler, which has a constructor containing two String arguments (username & password) and passing the CallbackHandler to the EJBClientConfiguration properties as following:
props.put("remote.connection.default.callback.handler.class", "test.SimpleAppCallbackHandler");
Example:
props.put("remote.connection.default.host", host);
props.put("remote.connection.default.port", port);
props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", false");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS","JBOSS-LOCAL-USER");
props.put("remote.connection.default.callback.handler.class", "test.SimpleAppCallbackHandler");
EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(props);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(selector);
- Any such attempt is causing the following exception:
WARN: Could not create connection for connection named default
java.lang.RuntimeException: java.lang.InstantiationException: test.SimpleAppCallbackHandler
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.resolveCallbackHandler(PropertiesBasedEJBClientConfiguration.java:602)
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.createCallbackHandler(PropertiesBasedEJBClientConfiguration.java:583)
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.createConnectionConfiguration(PropertiesBasedEJBClientConfiguration.java:511)
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.parseConnectionConfigurations(PropertiesBasedEJBClientConfiguration.java:457)
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.parseProperties(PropertiesBasedEJBClientConfiguration.java:220)
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.<init>(PropertiesBasedEJBClientConfiguration.java:112)
at client.JBossEJBClientAPIBased.testHelloSecure(Unknown Source)
at client.JBossEJBClientAPIBased.main(Unknown Source)
Caused by: java.lang.InstantiationException: test.SimpleAppCallbackHandler
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.resolveCallbackHandler(PropertiesBasedEJBClientConfiguration.java:600)
Environment
- JBoss Enterprise Application Platform (EAP)
- 6.0.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.