我有独立的 Java 客户端(在 eclipse 中运行),我希望连接到外部服务器。如果服务器是本地主机,那么我看不出有任何问题。但是,每当我尝试连接到外部服务器时,我总是会遇到以下异常
- JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
- Could not register a EJB receiver for connection to remote://10.160.148.61:4447
java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
我已尝试按照提到的步骤进行操作 EJB invocations from a remote client using JNDI
异常告诉我与身份验证相关的配置文件有问题。这是我的 ejb_client_properties 文件
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=10.160.148.61
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=tan
remote.connection.default.password=f2b1c3c7d3f1e224cbf6508494cf0418
注意:用户 tan 被添加到我在服务器上的 mgt.user.properties 文件中。我使用 add-user.bat 在服务器中添加用户。我还添加了一个应用程序用户。我使用相同的凭证传递给服务器。我想不出别的了。
我的ejb调用如下:
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext aJNDI = new InitialContext(jndiProperties);
Ppi handle = (Ppi) aJNDI
.lookup("ejb:PPIEAR/PService/PConnect!com.gem.p.PConnection?stateful");
我看到许多与异常相关的线程但无法修复它:(有人可以帮忙吗。
我还在服务器上安装了合法的 SSL 证书。我需要做一些额外的事情来处理吗?
另请注意:我的服务器以独立模式运行。
最佳答案
好的,我已经找到问题了。
是服务器端应用用户添加错误的情况。具体见下文。
[userone@localhost bin]$ ./add-user.sh
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): b
Enter the details of the new user to add.
Realm (ApplicationRealm) : ApplicationRealm ---->> Careful Here . You need to type this or leave it blank . I filled an incorrect value here and things went wrong from there .
Username : testuser
Password : testpassword
Re-enter Password : testpassword
What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none) : testrole
About to add user 'testuser' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-users.properties'
Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-users.properties'
Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-roles.properties'
Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-roles.properties'
.
.
我花了很长时间才弄明白这一点。相同的有用链接::http://middlewaremagic.com/jboss/?p=1466
关于javax.security.sasl.SaslException : Authentic Failed while connecting to Jboss 7 server from remote client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19129836/