如何从应用程序客户端连接远程 EJB 模块 [英] How to connect remote EJB module from application client

查看:29
本文介绍了如何从应用程序客户端连接远程 EJB 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在远程 Glassfish 服务器和计算机中的应用程序客户端中有一个 EJB 模块.我想从应用程序客户端连接到远程 EJB.

I have a EJB module in remote Glassfish server and application client in my computer. I want to connect from the application client to the remote EJB.

这是我的 EJB 接口:

Here is the my EJB interface:

@Remote
public interface BookEJBRemote
{
    public String getTitle();
}

这是我的 ejb:

Here is the my ejb:

@Stateless
public class BookEJB implements BookEJBRemote
{

    @Override
    public String getTitle()
    {
        return "Twenty Thousand Leagues Under the Sea";
    }
}

我有几个问题:

  1. 我可以在远程应用程序客户端中使用依赖注入连接到 ejb 吗?如果是这样,我该怎么做才能实现这一目标.我需要在sun-ejb-jar.xml 和sun-application-client.xml 中配置吗?换句话说,如果我像@EJB BookEJBRemote book那样使用依赖注入;应用程序客户端容器如何知道要注入什么 ejb?我应该在哪里指定信息?
  2. 如何运行应用程序客户端?我尝试在 glassfish 服务器中运行 package-appclient 以获取 appclient.jar 并将其复制到我的计算机.然后我输入 appclient.jar -client myAppClient.jar .它没有用.我如何指向目标服务器?
  3. 如果我不能在客户端使用依赖注入,那么我想我必须使用 JNDI 查找.我是否需要在 sun-ejb-jar.xml 或 sun-application-client.xml 中配置 jndi 名称?

无论我如何尝试,我都无法运行应用程序客户端?你们能举一些有效的例子吗?谢谢你的每一个建议和例子?

No matter how i try i never manage to run application client ? Can you guys put some working example? And thank you for every advises and examples?

推荐答案

查看此 教程创建 Java Stand-Alone客户.基本上你需要

Check this tutorial Creating a Java Stand-Alone Client. Basically you need to

  • 您自己设置 JNDI,因为您的客户端无法使用容器环境.
  • 查找远程接口.
  • 当然还要在类路径中包含所需的 jar 文件

这篇关于如何从应用程序客户端连接远程 EJB 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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