更新 該問題似乎與Ubuntu操作系統虛擬化有關,即我使用Vmware Workstation創建主機操作系統(Windows)和來賓操作系統(Ubuntu)。Windows客戶端和Linux(Ubuntu)服務器
當我在主機(Windows)上將EJB部署到Glassfish時;我可以在主機(Windows)或客戶機(Ubuntu)上使用servlet客戶機來查找EJB。我還可以指定主機或來賓的設置來查找EJB。我相信這就是問題所在,即無論主機設置或訪客設置是否在servlet中提供,查找總是在主機上完成。有沒有人有類似的經歷,你做了什麼來解決它。
原始的問題
請參閱下面的代碼:
Properties props = new Properties();
props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.163.128");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
try
{
InitialContext ctx = new InitialContext(props);
RemoteInterfaceRemote r = (RemoteInterfaceRemote) ctx.lookup("java:global/Course/RemoteInterface!com.w0051977.dao.RemoteInterfaceRemote");//!com.w0051977.dao.RemoteInterfaceRemote
String greeting = r.Greeting("Ian");
System.out.println("got here");
} catch (NamingException n)
{
System.out.println(n.toString());
}
的代碼中發現一個Servlet內,按預期工作胃內問候變量包含:「下午好」。 Servlet運行在Windows PC上,並連接到企業bean託管的Windows服務器。
但是,當我將bean移動到Linux(Ubuntu)PC時,我遇到了問題。上面的代碼將在Linux PC上的Servlet中運行(在這種情況下,客戶端和服務器在同一臺PC上)。但是,我無法獲得上面的代碼在Windows PC上的servlet中工作。
當Windows客戶端(servlet)連接到Linux(Ubuntu)服務器時,您有什麼特別的要做嗎?移動服務器時,我顯然會更改上面代碼中的IP地址。唯一的例外是:
Lookup failed for 'java:global/Course/RemoteInterface' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=ubuntu, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming
從Glassfish的控制檯(在Ubuntu)的輸出是:
[2016-10-14T08:57:16.824-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460636824] [levelValue: 800] [[
visiting unvisited references]]
[2016-10-14T08:57:16.890-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460636890] [levelValue: 800] [[
visiting unvisited references]]
[2016-10-14T08:57:17.238-0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460637238] [levelValue: 800] [[
Portable JNDI names for EJB RemoteInterface: [java:global/Course/RemoteInterface, java:global/Course/RemoteInterface!com.w0051977.dao.RemoteInterfaceRemote]]]
[2016-10-14T08:57:17.248-0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460637248] [levelValue: 800] [[
Glassfish-specific (Non-portable) JNDI names for EJB RemoteInterface: [com.w0051977.dao.RemoteInterfaceRemote#com.w0051977.dao.RemoteInterfaceRemote, com.w0051977.dao.RemoteInterfaceRemote]]]
[2016-10-14T08:57:17.432-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460637432] [levelValue: 900] [[
WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]
[2016-10-14T08:57:17.472-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460637472] [levelValue: 900] [[
WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]
[2016-10-14T08:57:17.482-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460637482] [levelValue: 900] [[
WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]
[2016-10-14T08:57:18.078-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=96 _ThreadName=admin-listener(7)] [timeMillis: 1476460638078] [levelValue: 800] [[
Course was successfully deployed in 1,282 milliseconds.]]
我已經花了好幾天尋找到這一點。請幫忙。
的輸出:命令lsof的-i:3700(請注意,我有NOE更改IP版本4按@RCs評論:
有在強制Ubuntu的時候回覆。從Windows PC PC
這裏是在Linux服務器上的JNDI樹:
遠程服務器上的JNDI查找名稱應該是什麼?我必須在本地Glassfish PC(Windows PC)上進行任何配置嗎?
我可以提供更多信息以鼓勵回覆嗎?我花了幾天的時間搜索並嘗試許多不同的東西。 – w0051977
你可以發佈'sudo lsof -i:3700'的輸出(從Ubuntu的機器運行)和'ping ubuntu'的輸出從Windows機器運行嗎? –
@RC,我已將該輸出發佈到原始帖子。謝謝。 – w0051977