J2EE 컨테이너가없는 JNDI (JNP 포함? 어쩌면 다른 공급자가 있습니까?)
문제
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 제공 업체를 제안 할 수 있다면 클라이언트가 작동하는 완전한 앱 서버없이 고객이 있습니다.
해결책
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
다른 팁
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
이 파일이 ClassPath에 있는지 확인하십시오. 그런 다음 이와 같은 주제/대기열을 조회 할 수 있습니다 (마이너스 적절한 시도/잡기) :
context = new InitialContext(properties);
context = (Context) context.lookup("java:comp/env/jms");
topicConnectionFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory");
topic = (Topic) context.lookup("myTopic");
JBoss JMQ는 마이크로 넬 및 최소한의 라이브러리 세트로 실행할 수도 있습니다. 설치 프로그램 인 JBOSS에는 "프로필"옵션이 있습니다. 그 중 하나는 독립형 JMQ입니다. 또한 구성 요소를 선택하고 선택할 수 있습니다 (종속성에 너무 도움이되지는 않지만). 설치 프로그램을 실행 해 보셨습니까?
제휴하지 않습니다 StackOverflow