0
我在JBOSS中部署了一個EJB應用程序。我在Jboss控制檯上得到了以下輸出。EJB jndi屬性
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)
您應該使用控制檯中列出的JNDI綁定之一,但錯誤似乎出現在身份驗證中。 (DIGEST-MD5:服務器拒絕認證)檢查用戶名和密碼,但在我看來,你正在試圖通過SSL與服務器通信,因此你需要一個證書。 –
您是否嘗試確認用戶確實存在,如果有,是否允許用戶執行遠程ejb呼叫。另外,你的ejb bean是否定義了一個遠程接口? – maress