GlassFish 应用程序客户端容器

发布于 2024-11-25 18:01:06 字数 1124 浏览 1 评论 0原文

我正在尝试使用 嵌入式 Glassfish 应用程序客户端容器。 我能找到的唯一资源是上面提到的 javadoc,其中包含这个诱人的代码片段

import org.glassfish.appclient.client.acc.AppClientContainer;
import org.glassfish.appclient.client.acc.config.TargetServer;

AppClientContainerBuilder builder = AppClientContainer.newBuilder(
   new TargetServer("localhost", 3700));

AppClientContainer acc = builder.newContainer(new File("myAC.jar").toURI());

(或者,),

AppClientContainer acc = builder.newContainer(MyClient.class);

然后,

acc.startClient(clientArgs);
// The newContainer method returns as soon as the client's main method returns,
// even if the client has started another thread or is using the AWT event
// dispatcher thread 
// At some later point, the program can synchronize with the app client in
// a user-specified way at which point it could invoke

acc.stop();

这看起来非常棒,但我尝试让它运行几次,并出现各种不同的错误。

有没有人有使用此功能的经验,或者他们可以向我指出一些解释如何使用此功能的资源的方向吗?

I'm trying to work with the Embeddable Glassfish app client container.
The only resources I can find are the above mentioned javadocs which contain this tantalising code snippet

import org.glassfish.appclient.client.acc.AppClientContainer;
import org.glassfish.appclient.client.acc.config.TargetServer;

AppClientContainerBuilder builder = AppClientContainer.newBuilder(
   new TargetServer("localhost", 3700));

AppClientContainer acc = builder.newContainer(new File("myAC.jar").toURI());

(or, alternatively)

AppClientContainer acc = builder.newContainer(MyClient.class);

then,

acc.startClient(clientArgs);
// The newContainer method returns as soon as the client's main method returns,
// even if the client has started another thread or is using the AWT event
// dispatcher thread 
// At some later point, the program can synchronize with the app client in
// a user-specified way at which point it could invoke

acc.stop();

This looks pretty awesome, but I've tried to get this to run a couple of times with various different errors.

Has anybody got any experience using this, or could they point me in the direction of some resources that explain how to work with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人疚 2024-12-02 18:01:07

There seems to be a decent bit of documentation around developing clients using the ACC on Oracle's site.

梅窗月明清似水 2024-12-02 18:01:06

我将其与 Glassfish 3.1.2 和一个简单的 Java Swing UI 应用程序一起使用。
TargetServer 指定的主机/端口似乎被忽略,我必须设置系统属性:

org.omg.CORBA.ORBInitialHost = hostname
org.omg.CORBA.ORBInitialPort = 2037

才能获得连接,因为我没有在默认端口上运行。

要全部编译,如果 Oracle 记录 AppClientContainer 等位于包中,将会有所帮助:

org.glassfish.appclient.client.acc

然后您可以找到编译所需的 .jar,它们是:

gf-client,jar, gf-client-module.jar, acc-config.jar

AppClientContainer.startClient 尝试调用一个方法:

public static void main(String[] args)

在 MyClient.class 上,这可能不完全是您想要的;就我而言,我的目标是使其与基于 Eclipse 的应用程序一起工作,该应用程序也希望“拥有”启动权。此外,我需要的 OSGI 环境似乎与 Glassfish ACC 完全不一致,它有自己不兼容的类加载机制。

尽管 startClient 调用需要它,但 main 方法似乎没有在单独的线程或任何特殊的东西中被调用。我发现我可以简单地提供一个虚拟主函数,它不执行任何操作,并且在 startClient 调用返回后立即拥有所有应用程序代码。

整个 ACC 实现似乎是将独立客户端连接到 Glassfish 3 上运行的应用程序的唯一受支持的方式。与 v2 的简单性相比,它相当不令人满意。庞大的 .jar 列表包含了我根本不感兴趣的各种内容,实际上在启动时我看到了这条消息:

15-May-2012 17:49:27 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.

Also Oracle has dumped an SLF4J logger implementation in bean-validator.jar which is colliding with my own favorite实施,导致进一步的错误消息。

Glassfish EJB 常见问题解答位于 http://glassfish.java.net/javaee5/ejb/EJB_FAQ。 html 已更新为 v3,也有一些帮助。

I have this working with Glassfish 3.1.2 and a simple Java Swing UI application.
The host/port specified by TargetServer appears to be ignored, I had to set the system properties:

org.omg.CORBA.ORBInitialHost = hostname
org.omg.CORBA.ORBInitialPort = 2037

to get a connection as I am not running on the default ports.

To get it all to compile, it would help if Oracle documented that AppClientContainer etc. are in package:

org.glassfish.appclient.client.acc

then you can find which .jars are needed for compilation, which were:

gf-client,jar, gf-client-module.jar, acc-config.jar

The AppClientContainer.startClient attempts to invokes a method:

public static void main(String[] args)

on MyClient.class, which might not be exactly what you want; In my case my goal is to make this work with an Eclipse-based application, which would also like to "own" the launch. In addition the OSGI environment I need seems to be completely at odds with the Glassfish ACC, having its own incompatible classloading mechanism.

Although it's needed for the startClient call, the main method doesn't seem to get called in a separate Thread or anything special. I found I can simply supply a dummy main which does nothing and have all my application code straight after the startClient call returns.

This whole ACC implementation seems to be the only supported way of connecting a standalone client to an application running on Glassfish 3. It is rather unsatisfactory compared to the simplicity available with v2. The huge list of .jars includes all sorts of things that are of no interest to me at all, indeed at startup I see this message:

15-May-2012 17:49:27 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.

Also Oracle have dumped an SLF4J logger implementation in bean-validator.jar which is colliding with my own preferred implementation, causing a further error message.

The Glassfish EJB FAQ at http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html has been updated for v3 and is also of some help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文