Windows客户端和Linux(Ubuntu)服务器 [英] Windows Client and Linux (Ubuntu) server

查看:177
本文介绍了Windows客户端和Linux(Ubuntu)服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新
问题似乎与Ubuntu操作系统虚拟化有关,即我使用Vmware Workstation创建主机操作系统(Windows)和客户操作system(Ubuntu)。

Update The problem appears to be related to the fact that the Ubuntu Operating System is virtualized i.e. I have used Vmware Workstation to create a host Operating system (Windows) and a guest operating system (Ubuntu).

当我在主机上部署EJB到Glassfish时(Windows);我可以在主机(Windows)或来宾(Ubuntu)上使用servlet客户端查找EJB。我还可以指定主机或guest虚拟机的设置来查找EJB。我相信这就是问题所在,即无论主机设置或访客设置是否在servlet中提供,查询总是在主机上完成。有没有人有类似的经历,你做了什么来解决它。

When I deploy the EJB to Glassfish on the host (Windows); I can lookup the EJB using a servlet client on either the host (Windows) or the guest (Ubuntu). I can also specify the settings for either the host or the guest to find the EJB. I believe this is what the issue is i.e. the lookup is always done on the host regardless of whether the host settings or guest settings are supplied in the servlet. Does anyone have a similar experience and what did you do to resolve it.

原始问题

请参阅以下代码:

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中找到并按预期工作。 greeting变量包含:Good Afternoon Ian。 Servlet在Windows PC上运行并连接到企业bean托管的Windows服务器。

The code is found inside a Servlet and works as expected i.g. the greeting variable contains: "Good Afternoon Ian". The Servlet runs on a Windows PC and connects to a Windows server were the enterprise bean is hosted.

然而,当我将bean移动到Linux(Ubuntu)PC时有问题。上面的代码将在Linux PC上的Servlet内运行(在这种情况下,客户端和服务器在同一台PC上)。但是,我无法让上面的代码在Windows PC上的servlet中工作。

However, when I move the bean to a Linux (Ubuntu) PC I have problems. The code above will run inside a Servlet on the Linux PC (the client and server are on the same pc in this case). However, I cannot get the code above to work inside a servlet on a Windows PC.

当Windows客户端(servlet)连接到Linux(Ubuntu)服务器时,你有什么特别的事吗?移动服务器时,我显然在上面的代码中更改了IP地址。例外情况是:

Is there anything special you have to do when a windows client (servlet) connects to a Linux (Ubuntu) server? I obviously change the IP address in the code above when moving server. The exception is:

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上)的输出是:

The output from the Glassfish console (on Ubuntu) is:

[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.]]

我花了好几天时间研究这个问题。请帮助。

I have spent days looking into this. Please help.

输出:sudo lsof -i:3700是(请注意,我已根据@RCs注释将IP版本更改为4:

The output of: sudo lsof -i:3700 is (note that I have noe changed the IP version to 4 as per @RCs comment:

从Windows ping Ubuntu PC时有回复PC。

There is a reply when Pinging the Ubuntu PC from the Windows PC.

这是Linux服务器上的JNDI树:

Here is the JNDI tree on the Linux server:

远程服务器上的JNDI查找名称应该是什么?我是否必须在本地Glassfish PC(Windows PC)上进行任何配置?

What should the JNDI lookup name be on the remote server? Do I have to do any configuration on the local Glassfish PC (Windows PC)?

推荐答案

听起来好像可能是防火墙问题。尝试从端口3700上的Windows机器telnet你的Linux机器。如果失败连接,添加防火墙规则以允许inc在端口3700上进行流量处理。这应该允许EJB通信。但您可能也想允许您的http / https传入请求。

It does sound like it might possibly be a firewall issue. Try telnet your Linux machine from the windows machine on port 3700. If that fails to connect, add firewall rules to allow incoming traffic on port 3700. This should allow for the EJB communication. But you might also want to allow your http / https incoming requests as well.

希望有所帮助。

这篇关于Windows客户端和Linux(Ubuntu)服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆