ClassCastException: SingleOption cannot be cast to Option when accessing initial context from JBoss to JBoss
sebbay Jun 21, 2012 2:03 AMHello,
I deployed 2 EAR's on one JBoss instance. The ejb's are included in A.ear. A class of B.ear is calling an ejb of A.ear.
To access the initial context (from B.ear), I use the following code:
InitialContext result = null;
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY, serverCtxFactory);
h.put(Context.PROVIDER_URL, "remote://10.2.5.81:10106");
h.put(Context.SECURITY_PRINCIPAL, appServerUser);
h.put(Context.SECURITY_CREDENTIALS, appServerPassword);
h.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
h.put("jboss.naming.client.ejb.context", true);
h.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
h.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
h.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
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", "10106");
pr.put("remote.connection.default.host", "10.2.5.81");
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", appServerUser);
pr.put("remote.connection.default.password", appServerPassword);
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(pr);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
result = new InitialContext(h);
This works, when accessing an ejb from a remote client, like a tomcat.
But when access the ejb on the same JBoss instance, I get the following error:
07:55:11,452 INFO [stdout] (Thread-71) java.lang.ClassCastException: org.xnio.SingleOption cannot be cast to org.xnio.Option
07:55:11,452 INFO [stdout] (Thread-71) at org.xnio.Option.fromString(Option.java:155)
07:55:11,452 INFO [stdout] (Thread-71) at org.xnio.OptionMap$Builder.parseAll(OptionMap.java:316)
07:55:11,453 INFO [stdout] (Thread-71) at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.getOptionMapFromProperties(PropertiesBasedEJBClientConfiguration.java:175)
07:55:11,453 INFO [stdout] (Thread-71) at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.parseProperties(PropertiesBasedEJBClientConfiguration.java:162)
07:55:11,453 INFO [stdout] (Thread-71) at org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.<init>(PropertiesBasedEJBClientConfiguration.java:110)
07:55:11,454 INFO [stdout] (Thread-71) at com.test.web.util.Translator.getInitialContext(Translator.java:880)
07:55:11,454 INFO [stdout] (Thread-71) at com.test.web.util.Translator.getTranslationManager(Translator.java:962)
07:55:11,454 INFO [stdout] (Thread-71) at com.test.web.util.Translator$1.run(Translator.java:610)
07:55:11,455 INFO [stdout] (Thread-71) at java.lang.Thread.run(Thread.java:662)
Has someone a solution for this problem?
Best regards,
sebbay