2011-12-15 152 views
3

嘗試以下(http://activemq.apache.org/jndi-support.html)使用JNDI運行得到的ActiveMQ和我擁有所有必需的ActiveMQ的罐子在我的JBoss /服務器/節點/ lib文件夾,我的jndi.properties樣子:ActiveMQ的JNDI查找問題

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 

,並具有以下生產者的代碼實際上產生的呼叫:

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

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) 

這個問題讓我感動的正確方向:ActiveMQInitialContextFactory vs. NamingContextFactory

+0

讓我知道,如果需要了解更多信息 – Rachel 2011-12-16 01:14:16

回答

2

我能得到它運行起來,問題是,我有一個jndi.properties文件,在該文件中,我有標準,

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

,因爲我們已經在我們的應用程序中使用jndi,所以我無法繼續修改​​這裏存在的文件,也無法添加我的activemq相關更改,因此解決方案是爲activemq創建不同的jndi.properties文件並獲取新的initialcontext把它作爲ActiveMQInitialContextFactory vs. NamingContextFactory提到的和其他的事情不得不作出肯定的是,我有兩個生產和發送方相同代理的信息,這是顯而易見的,它能正常工作。

添加信息,以便下一次有人在這個問題上的土地了,然後他或她不必花時間,我已經花出去搞清楚這件事。希望這會有所幫助。