Hi, You define the resource in tomee so use tomee initialcontext and not amq one ;)
New initialcontext() should be fine. - Romain Le 19 juil. 2012 13:38, "DONGARE Amol" <[email protected]> a écrit : > Hello, > > Greetings from me !!! > > I am new to tomee+. I have an issue - Not able to send messages to queue > created in tomee.xml file. Below is my configuration in tome.xml file- > > <Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter"> > # Broker configuration > # BrokerXmlConfig broker:(tcp://localhost:61617)?useJmx=false > # Broker address > ServerUrl vm://localhost?async=true > </Resource> > > <Resource id="test/jms" type="javax.jms.ConnectionFactory"> > TransactionSupport xa > PoolMaxSize 20 > </Resource> > <Resource id="abc/jms/test" type="javax.jms.Queue"> > destination test > </Resource> > > Then I have written client to send message to queue. Following is my > message sender code - > > Properties props = new Properties(); > props.put(Context.INITIAL_CONTEXT_FACTORY, > > "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); > props.put("java.naming.provider.url", "vm://localhost"); // > http://localhost:5000/tomee/ejb > InitialContext ic=new InitialContext(props); > > ConnectionFactory > factory=(ConnectionFactory)ic.lookup("ConnectionFactory"); > Connection connection = factory.createConnection(); > connection.start(); > > > Queue queue=(Queue)ic.lookup("abc/jms/test"); > // Create a Session > Session session = connection.createSession(false, > Session.AUTO_ACKNOWLEDGE); > > // Create a MessageProducer from the Session to the Topic or Queue > MessageProducer producer = session.createProducer(queue); > producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); > > // Create a message > TextMessage message = session.createTextMessage("Hello World!"); > > // Tell the producer to send the message > producer.send(message); > > After running above code I am getting following error - > > Jul 19, 2012 4:34:39 PM org.apache.activemq.broker.jmx.ManagementContext$1 > run > INFO: JMX consoles can connect to > service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi > Jul 19, 2012 4:34:39 PM org.apache.activemq.store.kahadb.plist.PListStore > doStart > INFO: PListStore:activemq-data\localhost\tmp_storage started > Jul 19, 2012 4:34:39 PM org.apache.activemq.broker.BrokerService start > INFO: Using Persistence Adapter: > KahaDBPersistenceAdapter[F:\EJB_Workspace\TOMEE_JMSP-P\activemq-data\localhost\KahaDB] > Jul 19, 2012 4:34:39 PM org.apache.kahadb.journal.Journal recoveryCheck > INFO: Corrupt journal records found in > 'activemq-data\localhost\KahaDB\db-1.log' between offsets: 315578-315908 > Jul 19, 2012 4:34:40 PM > org.apache.activemq.store.kahadb.MessageDatabase$Metadata read > INFO: KahaDB is version 3 > Jul 19, 2012 4:34:40 PM org.apache.activemq.store.kahadb.MessageDatabase > recover > INFO: Recovering from the journal ... > Jul 19, 2012 4:34:40 PM org.apache.activemq.store.kahadb.MessageDatabase > recover > INFO: Recovery replayed 2 operations from the journal in 0.017 seconds. > Jul 19, 2012 4:34:40 PM org.apache.activemq.broker.BrokerService getBroker > INFO: ActiveMQ 5.5.1 JMS Message Broker (localhost) is starting > Jul 19, 2012 4:34:40 PM org.apache.activemq.broker.BrokerService getBroker > INFO: For help or more information please see: http://activemq.apache.org/ > Jul 19, 2012 4:34:40 PM org.apache.activemq.broker.BrokerService start > INFO: ActiveMQ JMS Message Broker (localhost, > ID:AD1WIN764PLP-54123-1342695880393-0:1) started > Jul 19, 2012 4:34:40 PM org.apache.activemq.broker.TransportConnector start > INFO: Connector vm://localhost Started > Exception in thread "main" javax.naming.NameNotFoundException: abc/jms/test > at > org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > at com.example.ptp.SenderDemo_exp.sendMessage(SenderDemo_exp.java:37) > at com.example.ptp.SenderDemo_exp.main(SenderDemo_exp.java:21) > > > > YOUR HELP IS HIGHLY ANTICIPATED. > > > Thanks > Amol Dongare > > This email and any attachments are intended solely for the use of the > individual or entity to whom it is addressed and may be confidential and/or > privileged. > > If you are not one of the named recipients or have received this email in > error, > > (i) you should not read, disclose, or copy it, > > (ii) please notify sender of your receipt by reply email and delete this > email and all attachments, > > (iii) Dassault Systemes does not accept or assume any liability or > responsibility for any use of or reliance on this email. > > For other languages, go to http://www.3ds.com/terms/email-disclaimer >
