You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Marcus Zarra <mz...@mac.com> on 2006/06/13 21:31:43 UTC
Tomcat hang-up
Hopefully this is a simple question that has been answered before. I
am attempting to connect to an ActiveMQ broker from tomcat and the
broker is running on another machine. The tomcat version that is
being used is old enough that I cannot put a context.xml in place and
access the broker via a context lookup. Therefore I am simply
attempting to connect to the broker inside of the init method for a
servlet using the following code:
o = getServletContext().getAttribute("queueConnection");
Connection connection;
if (o == null) {
String jmsURL = getServletContext().getInitParameter
("JMS_URL");
log.info("URL is '" + jmsURL + "'");
ActiveMQConnectionFactory connectionFactory;
try {
log.info("Connecting to JMS");
connectionFactory = new ActiveMQConnectionFactory
(jmsURL);
log.info("Factory initialized");
connection = connectionFactory.createConnection();
log.info("Connection established");
connection.start();
log.info("Connection started");
getServletContext().setAttribute("queueConnection",
connection);
} catch (Throwable e) {
log.error("Error initializing JMS Connection", e);
throw new RuntimeException("Failed to initialize JMS
Connection");
}
} else {
connection = (QueueConnection)o;
}
There is some additional things going on in the init method but this
is the area having an issue. The issue is that the code stops dead
on connection.start() every time and locks so hard that I need to
kill -9 tomcat.
Has anyone seen and/or resolved this issue before? Or is there a
cleaner/safer way to establish a connection to a broker from inside
of a 4.x tomcat instance.
Thanks,
Marcus
Re: Tomcat hang-up
Posted by Marcus Zarra <mz...@mac.com>.
Note in this situation when the hang occurs there are no error logs
on either side of the connection.
On Jun 13, 2006, at 1:31 PM, Marcus Zarra wrote:
> Hopefully this is a simple question that has been answered before.
> I am attempting to connect to an ActiveMQ broker from tomcat and
> the broker is running on another machine. The tomcat version that
> is being used is old enough that I cannot put a context.xml in
> place and access the broker via a context lookup. Therefore I am
> simply attempting to connect to the broker inside of the init
> method for a servlet using the following code:
>
> o = getServletContext().getAttribute("queueConnection");
> Connection connection;
> if (o == null) {
> String jmsURL = getServletContext().getInitParameter
> ("JMS_URL");
> log.info("URL is '" + jmsURL + "'");
> ActiveMQConnectionFactory connectionFactory;
> try {
> log.info("Connecting to JMS");
> connectionFactory = new ActiveMQConnectionFactory
> (jmsURL);
> log.info("Factory initialized");
> connection = connectionFactory.createConnection();
> log.info("Connection established");
> connection.start();
> log.info("Connection started");
> getServletContext().setAttribute("queueConnection",
> connection);
> } catch (Throwable e) {
> log.error("Error initializing JMS Connection", e);
> throw new RuntimeException("Failed to initialize
> JMS Connection");
> }
> } else {
> connection = (QueueConnection)o;
> }
>
>
> There is some additional things going on in the init method but
> this is the area having an issue. The issue is that the code stops
> dead on connection.start() every time and locks so hard that I need
> to kill -9 tomcat.
>
> Has anyone seen and/or resolved this issue before? Or is there a
> cleaner/safer way to establish a connection to a broker from inside
> of a 4.x tomcat instance.
>
> Thanks,
>
> Marcus
Re: Tomcat hang-up
Posted by Marcus Zarra <mz...@mac.com>.
Thanks, I will give this a go tomorrow and let you know what I discover.
On Jun 14, 2006, at 12:34 AM, James Strachan wrote:
> See
>
> http://incubator.apache.org/activemq/how-can-i-enable-detailed-
> logging.html
>
> On 6/14/06, Marcus Zarra <mz...@mac.com> wrote:
>> Thanks for the reply. I am using a 4.0 build of ActiveMQ running on
>> Tomcat 4.x. When this test is being run there are no external
>> connections to the broker other than from Tomcat. Even in a
>> production environment there would not be more than 10.
>>
>> Is there any way to turn on additional logging so I can see what is
>> going on inside of ActiveMQ? The reason I ask is that if I kill the
>> broker (which is embedded inside of a standalone server application)
>> then tomcat comes back to life with some errors complaining about the
>> connection being broken. I would love to see what is stopping up the
>> works.
>>
>> BTW, The other "client" that connects to this broker that is not
>> inside of tomcat can talk with it just fine.
>>
>> I am stumped.
>>
>> Marcus
>>
>> On Jun 14, 2006, at 12:26 AM, James Strachan wrote:
>>
>> > BTW how many connections are being created? (Might be worth adding
>> > some logging).
>> > You could add some synchronization to ensure that you don't create
>> > lots of connections.
>> >
>> > On 6/14/06, James Strachan <ja...@gmail.com> wrote:
>> >> That code looks fine to me. I've no idea why this can be causing a
>> >> hang. Which version are you using?
>> >>
>> >> Does attempting to create a thread dump give you anything?
>> >>
>> >> On 6/13/06, Marcus Zarra <mz...@mac.com> wrote:
>> >> > Hopefully this is a simple question that has been answered
>> >> before. I
>> >> > am attempting to connect to an ActiveMQ broker from tomcat
>> and the
>> >> > broker is running on another machine. The tomcat version
>> that is
>> >> > being used is old enough that I cannot put a context.xml in
>> >> place and
>> >> > access the broker via a context lookup. Therefore I am simply
>> >> > attempting to connect to the broker inside of the init method
>> for a
>> >> > servlet using the following code:
>> >> >
>> >> > o = getServletContext().getAttribute
>> ("queueConnection");
>> >> > Connection connection;
>> >> > if (o == null) {
>> >> > String jmsURL = getServletContext
>> ().getInitParameter
>> >> > ("JMS_URL");
>> >> > log.info("URL is '" + jmsURL + "'");
>> >> > ActiveMQConnectionFactory connectionFactory;
>> >> > try {
>> >> > log.info("Connecting to JMS");
>> >> > connectionFactory = new
>> ActiveMQConnectionFactory
>> >> > (jmsURL);
>> >> > log.info("Factory initialized");
>> >> > connection =
>> connectionFactory.createConnection();
>> >> > log.info("Connection established");
>> >> > connection.start();
>> >> > log.info("Connection started");
>> >> > getServletContext().setAttribute
>> >> ("queueConnection",
>> >> > connection);
>> >> > } catch (Throwable e) {
>> >> > log.error("Error initializing JMS
>> Connection", e);
>> >> > throw new RuntimeException("Failed to
>> >> initialize JMS
>> >> > Connection");
>> >> > }
>> >> > } else {
>> >> > connection = (QueueConnection)o;
>> >> > }
>> >> >
>> >> >
>> >> > There is some additional things going on in the init method but
>> >> this
>> >> > is the area having an issue. The issue is that the code
>> stops dead
>> >> > on connection.start() every time and locks so hard that I
>> need to
>> >> > kill -9 tomcat.
>> >> >
>> >> > Has anyone seen and/or resolved this issue before? Or is
>> there a
>> >> > cleaner/safer way to establish a connection to a broker from
>> inside
>> >> > of a 4.x tomcat instance.
>> >> >
>> >> > Thanks,
>> >> >
>> >> > Marcus
>> >> >
>> >>
>> >>
>> >> --
>> >>
>> >> James
>> >> -------
>> >> http://radio.weblogs.com/0112098/
>> >>
>> >
>> >
>> > --
>> >
>> > James
>> > -------
>> > http://radio.weblogs.com/0112098/
>>
>>
>>
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
Re: Tomcat hang-up
Posted by James Strachan <ja...@gmail.com>.
See
http://incubator.apache.org/activemq/how-can-i-enable-detailed-logging.html
On 6/14/06, Marcus Zarra <mz...@mac.com> wrote:
> Thanks for the reply. I am using a 4.0 build of ActiveMQ running on
> Tomcat 4.x. When this test is being run there are no external
> connections to the broker other than from Tomcat. Even in a
> production environment there would not be more than 10.
>
> Is there any way to turn on additional logging so I can see what is
> going on inside of ActiveMQ? The reason I ask is that if I kill the
> broker (which is embedded inside of a standalone server application)
> then tomcat comes back to life with some errors complaining about the
> connection being broken. I would love to see what is stopping up the
> works.
>
> BTW, The other "client" that connects to this broker that is not
> inside of tomcat can talk with it just fine.
>
> I am stumped.
>
> Marcus
>
> On Jun 14, 2006, at 12:26 AM, James Strachan wrote:
>
> > BTW how many connections are being created? (Might be worth adding
> > some logging).
> > You could add some synchronization to ensure that you don't create
> > lots of connections.
> >
> > On 6/14/06, James Strachan <ja...@gmail.com> wrote:
> >> That code looks fine to me. I've no idea why this can be causing a
> >> hang. Which version are you using?
> >>
> >> Does attempting to create a thread dump give you anything?
> >>
> >> On 6/13/06, Marcus Zarra <mz...@mac.com> wrote:
> >> > Hopefully this is a simple question that has been answered
> >> before. I
> >> > am attempting to connect to an ActiveMQ broker from tomcat and the
> >> > broker is running on another machine. The tomcat version that is
> >> > being used is old enough that I cannot put a context.xml in
> >> place and
> >> > access the broker via a context lookup. Therefore I am simply
> >> > attempting to connect to the broker inside of the init method for a
> >> > servlet using the following code:
> >> >
> >> > o = getServletContext().getAttribute("queueConnection");
> >> > Connection connection;
> >> > if (o == null) {
> >> > String jmsURL = getServletContext().getInitParameter
> >> > ("JMS_URL");
> >> > log.info("URL is '" + jmsURL + "'");
> >> > ActiveMQConnectionFactory connectionFactory;
> >> > try {
> >> > log.info("Connecting to JMS");
> >> > connectionFactory = new ActiveMQConnectionFactory
> >> > (jmsURL);
> >> > log.info("Factory initialized");
> >> > connection = connectionFactory.createConnection();
> >> > log.info("Connection established");
> >> > connection.start();
> >> > log.info("Connection started");
> >> > getServletContext().setAttribute
> >> ("queueConnection",
> >> > connection);
> >> > } catch (Throwable e) {
> >> > log.error("Error initializing JMS Connection", e);
> >> > throw new RuntimeException("Failed to
> >> initialize JMS
> >> > Connection");
> >> > }
> >> > } else {
> >> > connection = (QueueConnection)o;
> >> > }
> >> >
> >> >
> >> > There is some additional things going on in the init method but
> >> this
> >> > is the area having an issue. The issue is that the code stops dead
> >> > on connection.start() every time and locks so hard that I need to
> >> > kill -9 tomcat.
> >> >
> >> > Has anyone seen and/or resolved this issue before? Or is there a
> >> > cleaner/safer way to establish a connection to a broker from inside
> >> > of a 4.x tomcat instance.
> >> >
> >> > Thanks,
> >> >
> >> > Marcus
> >> >
> >>
> >>
> >> --
> >>
> >> James
> >> -------
> >> http://radio.weblogs.com/0112098/
> >>
> >
> >
> > --
> >
> > James
> > -------
> > http://radio.weblogs.com/0112098/
>
>
>
>
--
James
-------
http://radio.weblogs.com/0112098/
Re: Tomcat hang-up
Posted by Marcus Zarra <mz...@mac.com>.
Thanks for the reply. I am using a 4.0 build of ActiveMQ running on
Tomcat 4.x. When this test is being run there are no external
connections to the broker other than from Tomcat. Even in a
production environment there would not be more than 10.
Is there any way to turn on additional logging so I can see what is
going on inside of ActiveMQ? The reason I ask is that if I kill the
broker (which is embedded inside of a standalone server application)
then tomcat comes back to life with some errors complaining about the
connection being broken. I would love to see what is stopping up the
works.
BTW, The other "client" that connects to this broker that is not
inside of tomcat can talk with it just fine.
I am stumped.
Marcus
On Jun 14, 2006, at 12:26 AM, James Strachan wrote:
> BTW how many connections are being created? (Might be worth adding
> some logging).
> You could add some synchronization to ensure that you don't create
> lots of connections.
>
> On 6/14/06, James Strachan <ja...@gmail.com> wrote:
>> That code looks fine to me. I've no idea why this can be causing a
>> hang. Which version are you using?
>>
>> Does attempting to create a thread dump give you anything?
>>
>> On 6/13/06, Marcus Zarra <mz...@mac.com> wrote:
>> > Hopefully this is a simple question that has been answered
>> before. I
>> > am attempting to connect to an ActiveMQ broker from tomcat and the
>> > broker is running on another machine. The tomcat version that is
>> > being used is old enough that I cannot put a context.xml in
>> place and
>> > access the broker via a context lookup. Therefore I am simply
>> > attempting to connect to the broker inside of the init method for a
>> > servlet using the following code:
>> >
>> > o = getServletContext().getAttribute("queueConnection");
>> > Connection connection;
>> > if (o == null) {
>> > String jmsURL = getServletContext().getInitParameter
>> > ("JMS_URL");
>> > log.info("URL is '" + jmsURL + "'");
>> > ActiveMQConnectionFactory connectionFactory;
>> > try {
>> > log.info("Connecting to JMS");
>> > connectionFactory = new ActiveMQConnectionFactory
>> > (jmsURL);
>> > log.info("Factory initialized");
>> > connection = connectionFactory.createConnection();
>> > log.info("Connection established");
>> > connection.start();
>> > log.info("Connection started");
>> > getServletContext().setAttribute
>> ("queueConnection",
>> > connection);
>> > } catch (Throwable e) {
>> > log.error("Error initializing JMS Connection", e);
>> > throw new RuntimeException("Failed to
>> initialize JMS
>> > Connection");
>> > }
>> > } else {
>> > connection = (QueueConnection)o;
>> > }
>> >
>> >
>> > There is some additional things going on in the init method but
>> this
>> > is the area having an issue. The issue is that the code stops dead
>> > on connection.start() every time and locks so hard that I need to
>> > kill -9 tomcat.
>> >
>> > Has anyone seen and/or resolved this issue before? Or is there a
>> > cleaner/safer way to establish a connection to a broker from inside
>> > of a 4.x tomcat instance.
>> >
>> > Thanks,
>> >
>> > Marcus
>> >
>>
>>
>> --
>>
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
Re: Tomcat hang-up
Posted by James Strachan <ja...@gmail.com>.
BTW how many connections are being created? (Might be worth adding
some logging).
You could add some synchronization to ensure that you don't create
lots of connections.
On 6/14/06, James Strachan <ja...@gmail.com> wrote:
> That code looks fine to me. I've no idea why this can be causing a
> hang. Which version are you using?
>
> Does attempting to create a thread dump give you anything?
>
> On 6/13/06, Marcus Zarra <mz...@mac.com> wrote:
> > Hopefully this is a simple question that has been answered before. I
> > am attempting to connect to an ActiveMQ broker from tomcat and the
> > broker is running on another machine. The tomcat version that is
> > being used is old enough that I cannot put a context.xml in place and
> > access the broker via a context lookup. Therefore I am simply
> > attempting to connect to the broker inside of the init method for a
> > servlet using the following code:
> >
> > o = getServletContext().getAttribute("queueConnection");
> > Connection connection;
> > if (o == null) {
> > String jmsURL = getServletContext().getInitParameter
> > ("JMS_URL");
> > log.info("URL is '" + jmsURL + "'");
> > ActiveMQConnectionFactory connectionFactory;
> > try {
> > log.info("Connecting to JMS");
> > connectionFactory = new ActiveMQConnectionFactory
> > (jmsURL);
> > log.info("Factory initialized");
> > connection = connectionFactory.createConnection();
> > log.info("Connection established");
> > connection.start();
> > log.info("Connection started");
> > getServletContext().setAttribute("queueConnection",
> > connection);
> > } catch (Throwable e) {
> > log.error("Error initializing JMS Connection", e);
> > throw new RuntimeException("Failed to initialize JMS
> > Connection");
> > }
> > } else {
> > connection = (QueueConnection)o;
> > }
> >
> >
> > There is some additional things going on in the init method but this
> > is the area having an issue. The issue is that the code stops dead
> > on connection.start() every time and locks so hard that I need to
> > kill -9 tomcat.
> >
> > Has anyone seen and/or resolved this issue before? Or is there a
> > cleaner/safer way to establish a connection to a broker from inside
> > of a 4.x tomcat instance.
> >
> > Thanks,
> >
> > Marcus
> >
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
--
James
-------
http://radio.weblogs.com/0112098/
Re: Tomcat hang-up
Posted by James Strachan <ja...@gmail.com>.
That code looks fine to me. I've no idea why this can be causing a
hang. Which version are you using?
Does attempting to create a thread dump give you anything?
On 6/13/06, Marcus Zarra <mz...@mac.com> wrote:
> Hopefully this is a simple question that has been answered before. I
> am attempting to connect to an ActiveMQ broker from tomcat and the
> broker is running on another machine. The tomcat version that is
> being used is old enough that I cannot put a context.xml in place and
> access the broker via a context lookup. Therefore I am simply
> attempting to connect to the broker inside of the init method for a
> servlet using the following code:
>
> o = getServletContext().getAttribute("queueConnection");
> Connection connection;
> if (o == null) {
> String jmsURL = getServletContext().getInitParameter
> ("JMS_URL");
> log.info("URL is '" + jmsURL + "'");
> ActiveMQConnectionFactory connectionFactory;
> try {
> log.info("Connecting to JMS");
> connectionFactory = new ActiveMQConnectionFactory
> (jmsURL);
> log.info("Factory initialized");
> connection = connectionFactory.createConnection();
> log.info("Connection established");
> connection.start();
> log.info("Connection started");
> getServletContext().setAttribute("queueConnection",
> connection);
> } catch (Throwable e) {
> log.error("Error initializing JMS Connection", e);
> throw new RuntimeException("Failed to initialize JMS
> Connection");
> }
> } else {
> connection = (QueueConnection)o;
> }
>
>
> There is some additional things going on in the init method but this
> is the area having an issue. The issue is that the code stops dead
> on connection.start() every time and locks so hard that I need to
> kill -9 tomcat.
>
> Has anyone seen and/or resolved this issue before? Or is there a
> cleaner/safer way to establish a connection to a broker from inside
> of a 4.x tomcat instance.
>
> Thanks,
>
> Marcus
>
--
James
-------
http://radio.weblogs.com/0112098/