Hello,
I'm using geronimo 2.0.1 and I try to send a simple textMessage to a JMSQueue.
First, I have configured a JMS-Ressource for ActiveMQ with the geronimo
console. You can see the full DeploymentPlan at the end of this email.
The Connectionfactory becomes the name: MyFactory
The Destination becomes the name: MyQueue
Now, I have a simple WebApplication, with a simple Servlet, which trys to send
a message to MyQueue
Here are the relevant code:
InitialContext jndiContext = getInitialContext();
QueueConnectionFactory factory = (QueueConnectionFactory)
jndiContext.lookup("java:comp/env/MyFactory");
Queue queue = (Queue) jndiContext.lookup("java:comp/env/MyQueue");
QueueConnection connection = factory.createQueueConnection();
QueueSession session = connection.createQueueSession(true,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
TextMessage txtMsg = session.createTextMessage();
txtMsg.setText(vorgangPk);
producer.send( txtMsg );
connection.close();
On line 2 jndiContext.lookup("java:comp/env/MyFactory"); a
NameNotFoundException is thrown (MyFactory not found).
I'm not sure what I do wrong. If anyone has an idea, it would be great.
Thanks a lot
Regards
Jochen
Here is the getInitialContext() Method
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
env.put(Context.PROVIDER_URL, "tcp://localhost:61616");
return new InitialContext(env);
geronimo-web.xml
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
<dep:moduleId>
<dep:groupId>com.accumio.ae</dep:groupId>
<dep:artifactId>EngineServlet</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dependency>
<groupId>console.jms</groupId>
<artifactId>pushae</artifactId>
<version>1.0</version>
<type>rar</type>
</dependency>
</dep:dependencies>
<dep:hidden-classes/>
<dep:non-overridable-classes/>
</dep:environment>
<context-root>/engineServlet</context-root>
</web-app>
the Deployment Plan for the JMS-Ressource:
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
<dep:environment
xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
<dep:moduleId>
<dep:groupId>console.jms</dep:groupId>
<dep:artifactId>pushae</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>rar</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>org.apache.geronimo.configs</dep:groupId>
<dep:artifactId>activemq-broker</dep:artifactId>
<dep:type>car</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<resourceadapter>
<resourceadapter-instance>
<resourceadapter-name>pushae</resourceadapter-name>
<config-property-setting
name="Clientid">pushaeClient</config-property-setting>
<nam:workmanager
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2">
<nam:gbean-link>DefaultWorkManager</nam:gbean-link>
</nam:workmanager>
</resourceadapter-instance>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
<connectiondefinition-instance>
<name>MyFactory</name>
<connectionmanager>
<xa-transaction>
<transaction-caching/>
</xa-transaction>
<single-pool>
<match-one/>
</single-pool>
</connectionmanager>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
<adminobject>
<adminobject-interface>javax.jms.Queue</adminobject-interface>
<adminobject-class>org.apache.activemq.command.ActiveMQQueue</adminobject-class>
<adminobject-instance>
<message-destination-name>MyQueue</message-destination-name>
<config-property-setting
name="PhysicalName">MyQueue2</config-property-setting>
</adminobject-instance>
</adminobject>
<adminobject>
<adminobject-interface>javax.jms.Topic</adminobject-interface>
<adminobject-class>org.apache.activemq.command.ActiveMQTopic</adminobject-class>
</adminobject>
</connector>
Thanks a lot
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066