Thanks a lot for your'e help. Finally I put the Jms-ressource in the application-scope and not in server-wide scope. I don't know why it does not run with server-wide scope. But this is okay for me.
Thanks a lot! regards Jochen! > -----Ursprüngliche Nachricht----- > Von: [email protected] > Gesendet: 24.09.07 21:47:28 > An: [email protected] > Betreff: Re: Problem JMS (NameNotFoundException) > > > On Sep 24, 2007, at 1:01 PM, David Carew wrote: > Do you have references to the ConnectionFactory and Queue in your web.xml ? > http://cwiki.apache.org/GMOxDOC20/jms-and-mdb-sample-application.html has an > example. Although the example uses annotations the setup would be the same to > be able to access the JMS resources via JNDI. > > > On 9/24/07, Jochen Zink <[EMAIL PROTECTED]> wrote: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); > > > I think this is the problem. This gives you the proprietary non-javaee > activemq jndi context that IIRC you have to configure with a properties file > somewhere. To use the javaee naming stuff you set up in your plans I think > you want just new InitialContext(). > > > The plans look ok to me, the important part is that the amq connector is > listed in the dependencies of the web app: this tells geronimo to try to hook > up the resource-ref etc to it. The names java:comp/env/MyQueue etc. look > correct to me. > > > thanks > david jencks > > > > > 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 > > > > ______________________________________________________________________ XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! Jetzt testen! http://produkte.web.de/club/?mc=021130
