dev@glassfish.java.net

Re: standalone apps & new InitialContext()

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Mon, 06 Nov 2006 20:08:01 +0530

Hi Oleksiy

This appears to be a bug. Even when the connection is closed, there
appears to be an active MQ client daemon thread which prevents the VM
from exiting. Could you file a GlassFish issue? We shall investigate
this further.

> "Timer-0" daemon prio=1 tid=0x09b4b328 nid=0x622f in Object.wait() [0xa72f8000..0xa72f8f30]
> at java.lang.Object.wait(Native Method)
> - waiting on <0xaa780068> (a java.util.TaskQueue)
> at java.util.TimerThread.mainLoop(Timer.java:509)
> - locked <0xaa780068> (a java.util.TaskQueue)
> at java.util.TimerThread.run(Timer.java:462)
>
> "iMQReadChannel-1" prio=1 tid=0x09b450d0 nid=0x622e runnable [0xa7379000..0xa7379eb0]
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
> at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
> at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
> - locked <0xaae3dfe8> (a java.io.BufferedInputStream)
> at com.sun.messaging.jmq.io.ReadOnlyPacket.readFully(ReadOnlyPacket.java:263)
> at com.sun.messaging.jmq.io.ReadOnlyPacket.readFixedHeader(ReadOnlyPacket.java:183)
> at com.sun.messaging.jmq.io.ReadOnlyPacket.readPacket(ReadOnlyPacket.java:143)
> at com.sun.messaging.jmq.io.ReadWritePacket.readPacket(ReadWritePacket.java:73)
> - locked <0xaa73e1f8> (a com.sun.messaging.jmq.io.ReadWritePacket)
> at com.sun.messaging.jmq.jmsclient.ProtocolHandler.readPacket(ProtocolHandler.java:1719)
> at com.sun.messaging.jmq.jmsclient.ReadChannel.run(ReadChannel.java:1139)
> at java.lang.Thread.run(Thread.java:595)
>
> "imqConnectionFlowControl-1" prio=1 tid=0x09b44c40 nid=0x622d in Object.wait() [0xa73fa000..0xa73fae30]
> at java.lang.Object.wait(Native Method)
> - waiting on <0xaae3e110> (a com.sun.messaging.jmq.jmsclient.FlowControl)
> at com.sun.messaging.jmq.jmsclient.FlowControl.run(FlowControl.java:290)
> - locked <0xaae3e110> (a com.sun.messaging.jmq.jmsclient.FlowControl)
> at java.lang.Thread.run(Thread.java:595)

Thanks
--Siva.

Oleksiy Stashok wrote:
> Hello,
>
>>>
>>> I'm trying to use GF JNDI namespace repository in standalone
>>> application (GFv2 b20).
>>> And have 2 problems:
>>> 1) Screens of logging text appear (Level.INFO).
>>> 2) After program completes execution it just hangs... And
>>> System.exit() is only solution, which helps.
>>>
>>> Are there any thoughts? May be I'm doing something wrong?
>>>
>>> Here is my code:
>>> / env.put("org.omg.CORBA.ORBInitialHost", host);
>>> env.put("org.omg.CORBA.ORBInitialPort", String.valueOf(port));
>>> InitialContext ic = new InitialContext(env);
>>> /
>> Are you using JMS resources and have you left any JMS session or
>> connection opened at the
>> end of the app?
>
> Here is simple app client attached, which hangs after sending a message.
> JMS Session and connection were closed.
> Is there something wrong in code?
>
> Thanks.
> Alexey.
>
>
> ------------------------------------------------------------------------
>
> /*
> * JMSTest.java
> */
>
> package test;
>
> import java.util.Properties;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.naming.InitialContext;
>
> public class JMSTest {
> public void process(String host, int port, String factory, String queue) throws Exception {
> Properties props = new Properties();
> props.setProperty("java.naming.factory.initial",
> "com.sun.enterprise.naming.SerialInitContextFactory");
> props.setProperty("java.naming.factory.url.pkgs",
> "com.sun.enterprise.naming");
> props.setProperty("java.naming.factory.state",
> "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
>
> props.put("org.omg.CORBA.ORBInitialHost", host);
> props.put("org.omg.CORBA.ORBInitialPort", String.valueOf(port));
>
> Connection connection = null;
> Session session = null;
> MessageProducer producer = null;
> TextMessage message = null;
>
> try {
> InitialContext ic = new InitialContext(props);
> ConnectionFactory connectionFactory = (ConnectionFactory) ic.lookup(factory);
> Queue destinationQueue = (Queue) ic.lookup(queue);
>
> connection = connectionFactory.createConnection();
> session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> producer = session.createProducer(destinationQueue);
>
> message = session.createTextMessage("Hello");
>
> producer.send(message);
>
> } finally {
> if (session != null) {
> try {
> session.close();
> } catch (JMSException ee) {
> }
> }
> if (connection != null) {
> try {
> connection.close();
> } catch (JMSException ee) {
> }
> }
> }
> }
>
> public static void main(String[] args) throws Exception {
> if (args.length < 4) {
> System.out.println("Run: JMSTest <host> <port> <jms-factory> <jms-queue>");
> System.exit(0);
> }
> String host = args[0];
> int port= Integer.parseInt(args[1]);
> String factory = args[2];
> String queue = args[3];
>
> new JMSTest().process(host, port, factory, queue);
>
> System.out.println("Message sent!");
> }
> }
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net