You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maciej Łabędzki <la...@man.poznan.pl> on 2006/06/02 09:53:51 UTC
Tomcat, ActiveMQ, 'jndi.properties' file problem
Hi,
i develope my web application using ActiveMQ and run it under Apache
Tomcat 5. There is a problem - the 'jndi.properties' file seems to be
invisible, although it is placed on class path.
Has anybody met such a problem?
Maciej
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat, ActiveMQ, 'jndi.properties' file problem
Posted by James Strachan <ja...@gmail.com>.
Where on the classpath did you place jndi.properties? Is it finding
another JNDI provider?
If you're having trouble with JNDI (which can sometimes be problematic
in different containers) you could try just use Spring instead. e.g.
see the activemq-web-console
http://incubator.apache.org/activemq/web-console.html
which doesn't use JNDI
On 6/2/06, Maciej Łabędzki <la...@man.poznan.pl> wrote:
> Hi,
> i develope my web application using ActiveMQ and run it under Apache
> Tomcat 5. There is a problem - the 'jndi.properties' file seems to be
> invisible, although it is placed on class path.
>
> Has anybody met such a problem?
>
> Maciej
>
>
>
--
James
-------
http://radio.weblogs.com/0112098/
Re: Tomcat, ActiveMQ, 'jndi.properties' file problem
Posted by Hadraba Petr <ha...@bluetone.cz>.
Hi,
sorry, I forgot to note, that the resources in the context.xml and
web.xml files are replacements for the jndi.properties. I'm using
Tomcat's build-in JNDI.
It looks like you're using one Queue with the name listenerDestination.
So, try the following:
META-INF/context.xml:
<Context>
...
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="ssl://localhost:32450"
brokerName="localhost"
useEmbeddedBroker="false" />
<Resource
name="jms/listenerDestination"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="dms.PublicLogQueue" />
...
</Context>
WEB-INF/web.xml:
...
<resource-env-ref>
<resource-env-ref-name>jms/ConnectionFactory</resource-env-ref-name>
<resource-env-ref-type>javax.jms.ConnectionFactory</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>jms/listenerDestination</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
...
And in the code you can obtain the Destination using
try {
InitialContext ic = new InitialContext();
Context ctx = (Context) ic.lookup("java:comp/env");
ConnectionFactory cf = (ConnectionFactory)
ctx.lookup("jms/ConnectionFactory");
Connection conn = (Connection) cf.createConnection();
conn.start();
Session s = conn.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
Destination d = (Destination)
ctx.lookup("jms/listenerDestination");
MessageProducer mp = s.createProducer(d);
mp.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage tm = s.createTextMessage();
tm.setText("Foo");
mp.send(tm);
tm = s.createTextMessage();
tm.setText("Bar");
mp.send(tm);
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
...
If you want to run ActiveMQ under Tomcat, not as standalone broker,
specify useEmbeddedBroker="true" in the context.xml.
The Resource tags can be also placed in the server.xml, but I have bad
experience with JDBC resources there, so I didn't try it.
Try the configuration above. This must work for you!
PETR
On 6/2/06, Maciej Łabędzki <la...@man.poznan.pl> wrote:
> Hadraba Petr napisał(a):
> > Hi Maciej,
> >
> > I'm connecting from Tomcat to ActiveMQ with this configuration:
> >
> Thx, but how it corresponds to my jndi.properties file?
> How should I form my configuration files (context.xml, web.xml)?
> jndi.properties:
> ---------------
> java.naming.factory.initial =
> org.activemq.jndi.ActiveMQInitialContextFactory
> brokerURL =ssl://localhost:32450
> queue.listenerDestination = dms.PublicLogQueue
>
>
> Maciej
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Petr Hadraba
graphic artist and software designer
http://people.hadraba-soft.com/~petr
hadrabap AT bluetone DOT cz
Re: Tomcat, ActiveMQ, 'jndi.properties' file problem
Posted by Maciej Łabędzki <la...@man.poznan.pl>.
Hadraba Petr napisał(a):
> Hi Maciej,
>
> I'm connecting from Tomcat to ActiveMQ with this configuration:
>
Thx, but how it corresponds to my jndi.properties file?
How should I form my configuration files (context.xml, web.xml)?
jndi.properties:
---------------
java.naming.factory.initial =
org.activemq.jndi.ActiveMQInitialContextFactory
brokerURL =ssl://localhost:32450
queue.listenerDestination = dms.PublicLogQueue
Maciej
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat, ActiveMQ, 'jndi.properties' file problem
Posted by Hadraba Petr <ha...@bluetone.cz>.
Hi Maciej,
I'm connecting from Tomcat to ActiveMQ with this configuration:
META-INF/context.xml:
<Context>
...
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://ws:61616"
brokerName="localhost"
useEmbeddedBroker="false" />
<Resource
name="jms/Test"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="TEST" />
...
</Context>
WEB-INF/web.xml:
...
<resource-env-ref>
<resource-env-ref-name>jms/ConnectionFactory</resource-env-ref-name>
<resource-env-ref-type>javax.jms.ConnectionFactory</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>jms/Test</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
...
Hope, it helps...
PETR
On 6/2/06, Maciej Łabędzki <la...@man.poznan.pl> wrote:
> Hi,
> i develope my web application using ActiveMQ and run it under Apache
> Tomcat 5. There is a problem - the 'jndi.properties' file seems to be
> invisible, although it is placed on class path.
>
> Has anybody met such a problem?
>
> Maciej
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Petr Hadraba
graphic artist and software designer
http://people.hadraba-soft.com/~petr
hadrabap AT bluetone DOT cz