5

J2EE コンテナーのオーバーヘッドなしで JNDI プロバイダーを実行する必要があります。私がやりたいことを正確に説明しているこの記事(3 ページ) の指示に従おうとしました。残念ながら、これらの指示は失敗します。jboss-common.jar もクラスパスに追加する必要がありました。これを行うと、スタック トレースが得られます。

$ java org.jnp.server.Main
0    [main] DEBUG
org.jboss.naming.Naming  - Creating
NamingServer stub, theServer=null,rmiPort=0,clientSocketFactory=null,serverSocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076[bindAddress=null]
Exception in thread "main"
java.lang.NullPointerException
     at org.jnp.server.Main.getNamingInstance(Main.java:301)
     at org.jnp.server.Main.initJnpInvoker(Main.java:354)
     at org.jnp.server.Main.start(Main.java:316)
     at org.jnp.server.Main.main(Main.java:104)

私はこれを機能させたいと思っていますが、他の軽量のスタンドアロン JNDI プロバイダーにもオープンです。これらはすべて ActiveMQ を機能させるためのものであり、VM の外部でうまく機能する別の軽量 JMS プロバイダーを誰かが提案できれば、クライアントも機能する本格的なアプリケーション サーバーがなくても問題ありません。

4

3 に答える 3

6

Apache ActiveMQには、統合された軽量の JNDI プロバイダーがすでに付属しています。使用方法については、こちらの説明を参照してください。

基本的に、jndi.properties ファイルをクラスパスに追加するだけで完了です。

java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory

# use the following property to configure the default connector
java.naming.provider.url = failover:tcp://localhost:61616

# use the following property to specify the JNDI name the connection factory
# should appear as. 
#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue


# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic
于 2008-10-13T09:10:33.830 に答える
2

次のように jndi.properties ファイルを使用します。

java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory

# use the following property to configure the default connector
java.naming.provider.url=tcp://jmshost:61616

# use the following property to specify the JNDI name the connection factory
# should appear as. 
#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
#queue.MyQueue = example.MyQueue


# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.myTopic = MY.TOPIC

このファイルがクラスパスにあることを確認してください。次に、次のようにトピック/キューを検索できます (適切な試行/キャッチを除く):

context = new InitialContext(properties);

context = (Context) context.lookup("java:comp/env/jms");

topicConnectionFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory");

topic = (Topic) context.lookup("myTopic");
于 2008-10-10T20:34:43.267 に答える
1

JBoss JMQ は、MicroKernel と最小限のライブラリ セットだけで実行することもできます。JBoss AS インストーラーには「プロファイル」のオプションがあり、そのうちの 1 つはスタンドアロン JMQ 用です。また、コンポーネントを選択して選択することもできます (ただし、依存関係についてはあまり役に立ちません)。インストーラーを実行してみましたか?

于 2008-10-10T19:23:53.937 に答える