我正在编写一个独立的程序来调用EJB。 EJB被部署到我的本地JBoss服务器上。我遵循这里的指导方针: http://www.mastertheboss.com/jboss-server/jboss-as-7/jboss-as-7-remote-ejb-client-tutorial?showall=
当我执行主要问题时,它会抛出
javax.ejb.EJBAccessException: JBAS013323: Invalid User
javax.ejb.EJBAccessException: JBAS013323: Invalid User
at org.jboss.as.ejb3.security.SecurityContextInterceptor$1.run(SecurityContextInterceptor.java:54)
at org.jboss.as.ejb3.security.SecurityContextInterceptor$1.run(SecurityContextInterceptor.java:45)
at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:78)
有谁知道我错过了什么?谢谢你的帮助。
我的主要计划:
private void start() throws Exception {
logger.info("----------------------program start--------------------------");
Context context = null;
try {
init();
final Hashtable<String, Object> jndiProperties = new Hashtable<>();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put("jboss.naming.client.ejb.context",true);
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProperties.put(Context.PROVIDER_URL,"remote://localhost:4447");
context = new InitialContext(jndiProperties);
GrainReportManagerRemote grainReportManagerRemote = (GrainReportManagerRemote) context.lookup("java:GrainEar/GrainEJB/GrainReportManager!"+ GrainReportManagerRemote.class.getName());
grainReportManagerRemote.export();
} catch (Exception e) {
logger.error(e, e);
} finally {
if (context != null)
context.close();
}
logger.info("----------------------program end--------------------------");
}
jboss-ejb-client.properties:
endpoint.name = client-endpoint
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS = false
remote.connection.default.host = localhost
remote.connection.default.port = 4447
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED = false
remote.connections = default
remote.connection.default.username=appuser
remote.connection.default.password=appuser`123
答案 0 :(得分:1)
我在Jboss 7.1.1上测试了你的代码,它给了我另一个例外:SaslException: Authentication failed
请尝试两件对我有用的事情。
添加:
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
或删除这3行:
jndiProperties.put("jboss.naming.client.ejb.context",true);
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProperties.put(Context.PROVIDER_URL,"remote://localhost:4447");