Glassfish V3.x 和远程独立客户端

Glassfish V3.x and remote standalone client(Glassfish V3.x 和远程独立客户端)

本文介绍了Glassfish V3.x 和远程独立客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为独立客户端连接到 ActiveMQ 绝对没有问题.您唯一需要做的就是添加 activemq-all-5.4.1.jar 就可以了...

<代码>...prop.put(Context.SECURITY_AUTHENTICATION , "系统");prop.put(Context.SECURITY_CREDENTIALS,"经理");prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");prop.put(Context.PROVIDER_URL,"tcp://localhost:61616");prop.put("connectionFactoryNames", "TopicCF");prop.put("topic.topic1", "topic1");InitialContext ctx = new InitialContext(prop);...

现在您想要连接到 Glassfish V3.x,并且似乎不可能获得正确的库和类来进行连接.虽然在 Glassfish V2.x 中仍然有可能,但我还没有成功地为 Glassfish 运行上述代码!

<代码>...属性属性 = 新属性();properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory");properties.put(Context.PROVIDER_URL, "iiop://localhost:3700");InitialContext 上下文 = 新 InitialContext(属性)...

有人对此有答案吗?不,我不想部署企业应用程序客户端只是为了从 Glassfish 队列中读取.这里有类似的主题,但没有任何指南.

感谢任何提示

斯文

解决方案

连接到 Glassfish V3 时,无需向 InitialContext 构造函数提供任何属性.您可以简单地使用无参数构造函数.要指定服务器名称和端口,请分别在 JVM 上设置 -Dorg.omg.CORBA.ORBInitialHost 和 -Dorg.omg.CORBA.ORBInitialPort 属性.p>

至于库,您只需要包含 gf-client.jar 文件即可.它可以在 $GLASSFISH_HOME/lib 中找到.此 jar 文件将自动包含所需的任何其他库.

有关详细信息,请参阅 http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB.尽管该文档涉及在独立客户端中使用 EJB,但同样的解决方案也适用于使用 JMS.

it is absolutely no problem to connect to a ActiveMQ as standalone client. The only thing you need is to add the activemq-all-5.4.1.jar and there you go...

...
prop.put(Context.SECURITY_AUTHENTICATION , "system");
prop.put(Context.SECURITY_CREDENTIALS,"manager");
prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
prop.put(Context.PROVIDER_URL,"tcp://localhost:61616");
prop.put("connectionFactoryNames", "TopicCF");
prop.put("topic.topic1", "topic1");

InitialContext ctx = new InitialContext(prop);
...

Now you want to connect to Glassfish V3.x and it seems impossible to get the right libraries and classes in order to connect. While it still was possible in Glassfish V2.x I did not succeed yet to get the equivalent of above code running for Glassfish !

...
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory");
properties.put(Context.PROVIDER_URL, "iiop://localhost:3700");
InitialContext context = new InitialContext(properties)
...

Does anyone have an answer on this ? No, I dont want to deploy an enterprise app-client just to read from a Glassfish queue. There are similar threads here, but none guides anywhere.

Thanks for any tips

Sven

解决方案

When connecting to Glassfish V3, there is no need to supply any properties to the InitialContext constructor. You can simply use the no-arg constructor. To specify the server name and port, set the -Dorg.omg.CORBA.ORBInitialHost and -Dorg.omg.CORBA.ORBInitialPort properties on the JVM, respectively.

As for the libraries, all you should need to include is the gf-client.jar file. It can be found at $GLASSFISH_HOME/lib. This jar file will automatically include whatever other libraries are needed.

For more information, please see http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB. Although that document addresses using EJBs in a stand-alone client, the same solutions apply to using JMS.

这篇关于Glassfish V3.x 和远程独立客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Glassfish V3.x 和远程独立客户端

基础教程推荐