Java ejbjndi属性

Java ejbjndi属性,java,jakarta-ee,jboss,Java,Jakarta Ee,Jboss,我在JBOSS中部署了一个EJB应用程序。我在Jboss控制台上获得了以下输出 18:52:59,762 INFO [org.jboss.as.server.deployment] (MSC service thread 1-10) JBAS015876: Starting deployment of "EJBModule1.jar" 18:52:59,880 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeplo

我在JBOSS中部署了一个EJB应用程序。我在Jboss控制台上获得了以下输出

18:52:59,762 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-10) JBAS015876: Starting deployment of "EJBModule1.jar"
18:52:59,880 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named LibrarySessionBean in deployment unit deployment "EJBModule1.jar" are as follows:

    java:global/EJBModule1/LibrarySessionBean!com.wso2.tutorial.LibrarySessionBeanRemote
    java:app/EJBModule1/LibrarySessionBean!com.wso2.tutorial.LibrarySessionBeanRemote
    java:module/LibrarySessionBean!com.wso2.tutorial.LibrarySessionBeanRemote
    java:jboss/exported/EJBModule1/LibrarySessionBean!com.wso2.tutorial.LibrarySessionBeanRemote
    java:global/EJBModule1/LibrarySessionBean
    java:app/EJBModule1/LibrarySessionBean
    java:module/LibrarySessionBean

18:53:00,062 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "EJBModule1.jar"
如何从上面的日志中找到要传递给ctx.lookup()的参数。 我当前的属性如下所示

 Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");
        jndiProps.put(Context.SECURITY_PRINCIPAL, "testuser");
        jndiProps.put(Context.SECURITY_CREDENTIALS, "testuser123");
        jndiProps.put("jboss.naming.client.ejb.context", true);
        Context ctx = new InitialContext(jndiProps);

        final String appName = "EJBModule1";
        final String moduleName = "LibrarySessionBeanRemote";
        final String distinctName = "";
        final String beanName = "com.wso2.tutorial.LibrarySessionBean";

        final String viewClassName = LibrarySessionBean.class.getName();
        System.out.println("Looking EJB via JNDI ");
        System.out.println("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

        return ctx.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);
这会产生以下错误

Oct 05, 2015 7:36:26 PM org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed:
   DIGEST-MD5: Server rejected authentication
Exception in thread "main" javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:4447]
    at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:213)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:144)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:125)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:241)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.sample.ejb.RemoteEJBClient.lookupRemoteEJB(RemoteEJBClient.java:42)
    at com.sample.ejb.RemoteEJBClient.testRemoteEJB(RemoteEJBClient.java:17)
    at com.sample.ejb.RemoteEJBClient.main(RemoteEJBClient.java:13)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

您需要使用Jboss控制台中的绑定。jboss jndi端口的默认端口是1099。尝试使用此端口号

您应该使用控制台中列出的JNDI绑定之一,但是,错误似乎出现在身份验证中。(DIGEST-MD5:Server rejected authentication)检查用户名和密码,但在我看来,您需要通过SSL与服务器通信,因此您需要证书。您是否尝试确认该用户确实存在,如果存在,是否允许该用户进行远程ejb调用。此外,您的ejb bean是否定义了远程接口?这对于wildfly/jboss中的远程ejb调用不起作用。必须使用导出的jndi命名空间:
ejb://