ActiveMQ JNDI查找问题 [英] ActiveMQ JNDI Lookup Issues

查看:184
本文介绍了ActiveMQ JNDI查找问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过运行JNDI来获取ActiveMQ( http://activemq.apache.org/jndi-support.html),并且我的jboss/server/node/lib文件夹中具有所有必需的activeMQ jar,而我的jndi.properties看起来像:

Trying to get ActiveMQ with JNDI running following (http://activemq.apache.org/jndi-support.html) and i have all the required activeMQ jars in my jboss/server/node/lib folder and my jndi.properties looks like:

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

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

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

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


# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic

,并在生产器中包含以下代码,这些代码实际上会产生调用:

and have following piece of code in producer which actually produces the call:

InitialContext ic = null;
ConnectionFactory factory = null;
Connection con = null;
Session session = null;
Queue queue = null;
MessageProducer producer = null;

ic = new InitialContext();
factory = (ConnectionFactory) ic.lookup("connectionFactoryNames");
con = factory.createConnection();
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
queue = (Queue)ic.lookup("queue/TESTQUEUE");
producer = session.createProducer(queue);
// Then... send the message.
producer.send(session.createObjectMessage(new Long(Id)));

这是一个例外,不确定scheme java not recognized

and here is the exception am getting, not sure what does it mean by scheme java not recognized

WARN org.jboss.system.ServiceController - Problem starting service jboss:service=Naming
javax.naming.NamingException: scheme java not recognized
    at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:221)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.jboss.naming.NamingService.startService(NamingService.java:274)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at org.jboss.system.ServiceController.start(ServiceController.java:435)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:490)
    at java.lang.Thread.run(Thread.java:662)

这个问题使我朝着正确的方向前进: ActiveMQInitialContextContext vs NamingContextFactory

This question moved me in proper direction: ActiveMQInitialContextFactory vs. NamingContextFactory

推荐答案

我能够启动并运行它,问题是我有一个jndi.properties文件,并且在该文件中我有标准文件,

I was able to get it up and running, issue was that i had one jndi.properties file and in that file i have standard,

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

,因为我们已经在应用程序中使用了jndi,所以我无法继续修改​​此处存在的文件,也无法在此处添加与activemq相关的更改,因此解决方案是为jndi.properties文件>并按照 ActiveMQInitialContextContext vs NamingContextFactory 中所述添加新的initialcontext,并且必须进行其他操作可以肯定的是,对于生产者和发送者而言,我都具有相同的经纪人信息,这很明显并且可以正常工作.

and as we were already using jndi in our application, i could not go ahead an modify files present here and also cannot add my activemq related changes in here and so solution was to create different jndi.properties file for activemq and get new initialcontext to it as mentioned in ActiveMQInitialContextFactory vs. NamingContextFactory and other thing had to make sure is that i have same broker information for both producer and sender side, which is obvious and it worked fine.

添加信息,以便下次有人提出该问题时,他或她就不必花费我已经花费在弄清楚这个问题上的时间.希望这会有所帮助.

Adding information so that next time someone lands up on this question then he or she does not have to spend time which i have already spend figuring this thing out. Hope this would help.

这篇关于ActiveMQ JNDI查找问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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