Problem Running standalone JMS program - Websphere

This is a discussion on Problem Running standalone JMS program - Websphere ; Hi all, I am new to websphere , i am tring to write a simple standalone JMS program to send and receive msg .I am using Websphere V 6.0.0.1 as application server. I have successfully created Queue connection factory and ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Problem Running standalone JMS program

  1. Problem Running standalone JMS program


    Hi all,

    I am new to websphere , i am tring to write a simple standalone JMS program to send and receive msg .I am using Websphere V 6.0.0.1 as application server.
    I have successfully created Queue connection factory and JMS Queue using default messaging . Lookup to the Connection factory was successful ,but i am getting an exception during creating of Queue connection.

    The code is as given below :

    import java.util.*;
    import javax.naming.*;
    import javax.jms.*;

    public class ThinClientJMSSender
    {

    private QueueConnectionFactory qconFactory;
    private QueueConnection qcon;
    private QueueSession qsession;
    private QueueSender qsender;
    private Queue queue;
    private TextMessage msg;
    private InitialContext ctx;

    public ThinClientJMSSender()
    {
    loadProperties();
    setContext();
    }


    public void init()
    {
    try
    {
    qconFactory = (QueueConnectionFactory) ctx.lookup(FactoryLookup);
    qcon = qconFactory.createQueueConnection(); <-------- Point of exception
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queue = (Queue) ctx.lookup(QueueLookup);
    qsender = qsession.createSender(queue);
    msg = qsession.createTextMessage();
    qcon.start();
    }
    catch(Exception e)
    {
    printStackTrace();
    }
    }
    private InitialContext getInitialContext()
    {
    Hashtable env=null;
    InitialContext ic1 = null;
    try
    {
    env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
    env.put(Context.PROVIDER_URL, url);
    ic1= new InitialContext(env);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    return ic1;
    }

    private void loadProperties()
    {
    try
    {
    url ="iiop://206.251.112.26:2810/";
    FactoryLookup="factorylookup";
    QueueLookup= "quelookup1";
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }




    The exception is as follow :

    Dec 8, 2005 9:58:23 PM com.ibm.ws.sib.utils.ras.SibMessage
    WARNING: SIB_MESSAGE
    Dec 8, 2005 9:58:23 PM com.ibm.ws.channel.framework.impl.WSChannelFramewo rkImpl
    AUDIT: chain.started
    Dec 8, 2005 9:58:23 PM com.ibm.ws.channel.framework.impl.WSChannelFramewo rkImpl
    AUDIT: chain.started
    Dec 8, 2005 9:58:25 PM com.ibm.ws.sib.utils.ras.SibMessage
    WARNING: SIB_MESSAGE
    javax.jms.JMSException: CWSIA0241E: An exception was received during the call to the method JmsManagedConnectionFactoryImpl.createConnection: com.ibm.websphere.sib.exception.SIResourceExceptio n: CWSIT0006E: It is not possible to contact a messaging engine in bus system-r1Node02SamplesBus..
    at com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFa ctoryImpl.createConnection(JmsManagedConnectionFac toryImpl.java:225)
    at com.ibm.ws.sib.api.jms.impl.JmsQueueConnectionFact oryImpl.createQueueConnection(JmsQueueConnectionFa ctoryImpl.java:149)
    at com.ibm.ws.sib.api.jms.impl.JmsQueueConnectionFact oryImpl.createQueueConnection(JmsQueueConnectionFa ctoryImpl.java:113)
    at ThinClientJMSSender.init(ThinClientJMSSender.java: 42)
    at ThinClientJMSSender.setContext(ThinClientJMSSender .java:28)
    at ThinClientJMSSender.(ThinClientJMSSender.java:20)
    at ThinClientJMSSender.main(ThinClientJMSSender.java: 117)


    Can someone please help me :-((

    Thanks in advance,
    Deepak

  2. Re: Problem Running standalone JMS program

    Deepak,

    Firstly, I'd suggest you'll probably get more helpful advice from the
    ibm.software.websphere.application-server newsgroup than
    ibm.software.websphere.mq, since the default messaging provider in WebSphere
    Application Server v6 is not based on WebSphere MQ.

    Anyway, the problem you report is probably some mismatch between the
    connection factory properties you have looked up and the configuration of
    the bus you are trying to connect into. As a starting point, have a look at
    the provider endpoints property of the connection factory (probably easiest
    to use the Admin Console to look at the properties of the connection factory
    defined in COS Naming). The default will be localhost:7276. Whatever
    server you are connecting to on this provider endpoint must be able to
    connect you into the specified bus, and must be able to direct you to a
    valid, running messaging engine within that bus.

    Brian

    wrote in message
    news:2086091998.1134126547675.JavaMail.wassrvr@lts gwas007.sby.ibm.com...
    >
    > Hi all,
    >
    > I am new to websphere , i am tring to write a simple standalone JMS

    program to send and receive msg .I am using Websphere V 6.0.0.1 as
    application server.
    > I have successfully created Queue connection factory and JMS Queue using

    default messaging . Lookup to the Connection factory was successful ,but i
    am getting an exception during creating of Queue connection.
    >
    > The code is as given below :
    >
    > import java.util.*;
    > import javax.naming.*;
    > import javax.jms.*;
    >
    > public class ThinClientJMSSender
    > {
    >
    > private QueueConnectionFactory qconFactory;
    > private QueueConnection qcon;
    > private QueueSession qsession;
    > private QueueSender qsender;
    > private Queue queue;
    > private TextMessage msg;
    > private InitialContext ctx;
    >
    > public ThinClientJMSSender()
    > {
    > loadProperties();
    > setContext();
    > }
    >
    >
    > public void init()
    > {
    > try
    > {
    > qconFactory = (QueueConnectionFactory) ctx.lookup(FactoryLookup);
    > qcon = qconFactory.createQueueConnection(); <-------- Point of exception
    > qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    > queue = (Queue) ctx.lookup(QueueLookup);
    > qsender = qsession.createSender(queue);
    > msg = qsession.createTextMessage();
    > qcon.start();
    > }
    > catch(Exception e)
    > {
    > printStackTrace();
    > }
    > }
    > private InitialContext getInitialContext()
    > {
    > Hashtable env=null;
    > InitialContext ic1 = null;
    > try
    > {
    > env = new Hashtable();
    > env.put(Context.INITIAL_CONTEXT_FACTORY,

    "com.ibm.websphere.naming.WsnInitialContextFactory");
    > env.put(Context.PROVIDER_URL, url);
    > ic1= new InitialContext(env);
    > }
    > catch(Exception e)
    > {
    > e.printStackTrace();
    > }
    > return ic1;
    > }
    >
    > private void loadProperties()
    > {
    > try
    > {
    > url ="iiop://206.251.112.26:2810/";
    > FactoryLookup="factorylookup";
    > QueueLookup= "quelookup1";
    > }
    > catch(Exception e)
    > {
    > e.printStackTrace();
    > }
    > }
    >
    >
    >
    >
    > The exception is as follow :
    >
    > Dec 8, 2005 9:58:23 PM com.ibm.ws.sib.utils.ras.SibMessage
    > WARNING: SIB_MESSAGE
    > Dec 8, 2005 9:58:23 PM

    com.ibm.ws.channel.framework.impl.WSChannelFramewo rkImpl
    > AUDIT: chain.started
    > Dec 8, 2005 9:58:23 PM

    com.ibm.ws.channel.framework.impl.WSChannelFramewo rkImpl
    > AUDIT: chain.started
    > Dec 8, 2005 9:58:25 PM com.ibm.ws.sib.utils.ras.SibMessage
    > WARNING: SIB_MESSAGE
    > javax.jms.JMSException: CWSIA0241E: An exception was received during the

    call to the method JmsManagedConnectionFactoryImpl.createConnection:
    com.ibm.websphere.sib.exception.SIResourceExceptio n: CWSIT0006E: It is not
    possible to contact a messaging engine in bus system-r1Node02SamplesBus..
    > at

    com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFa ctoryImpl.createConnection
    (JmsManagedConnectionFactoryImpl.java:225)
    > at

    com.ibm.ws.sib.api.jms.impl.JmsQueueConnectionFact oryImpl.createQueueConnect
    ion(JmsQueueConnectionFactoryImpl.java:149)
    > at

    com.ibm.ws.sib.api.jms.impl.JmsQueueConnectionFact oryImpl.createQueueConnect
    ion(JmsQueueConnectionFactoryImpl.java:113)
    > at ThinClientJMSSender.init(ThinClientJMSSender.java: 42)
    > at ThinClientJMSSender.setContext(ThinClientJMSSender .java:28)
    > at ThinClientJMSSender.(ThinClientJMSSender.java:20)
    > at ThinClientJMSSender.main(ThinClientJMSSender.java: 117)
    >
    >
    > Can someone please help me :-((
    >
    > Thanks in advance,
    > Deepak




  3. Re: Problem Running standalone JMS program

    Hi Brian,
    Thanks for the reply,

    I couldnt go about sending a msg to a queue using thin-client, I checked the provider endpoint it is correct , AppServerip:BootStrapAddress .

    Anyway now i was trying to use Application Client(launchclient too) to send a msg to a queue. I have created the QueueConnectionFactory and the queue on both server using the wizard and on the client side using clientConfig. But still no luck :-((
    Actually i was wondering how client program knows the info bout the app server ( I think coz we mention the server info during the client installation time , it always refers to the server , is this the case ???)

    My code is :


    import com.ibm.etools.service.locator.ServiceLocatorManag er;
    import javax.jms.*;
    import javax.naming.*;
    public class Main
    {

    public static void main(String[] args)
    {
    try
    {
    String messageID = null;
    String outString = "hii";
    String qcfName = "java:comp/env/jms/ConnectionFactory";
    String qnameIn = "java:comp/env/jms/Q1";
    String qnameOut = "java:comp/env/jms/Q2";
    boolean verbose = false;
    QueueSession session = null;
    QueueConnection connection = null;
    Context ctx = null;
    QueueConnectionFactory qcf = null;
    Queue inQueue = null;
    Queue outQueue = null;

    ctx = new InitialContext();
    qcf = (QueueConnectionFactory)ctx.lookup(qcfName);
    inQueue = (Queue)ctx.lookup(qnameIn);
    outQueue = (Queue)ctx.lookup(qnameOut);
    connection = qcf.createQueueConnection();
    connection.start();
    boolean transacted = false;
    session = connection.createQueueSession( transacted,
    Session.AUTO_ACKNOWLEDGE);
    QueueSender queueSender = session.createSender(inQueue);
    TextMessage outMessage = session.createTextMessage(outString);
    queueSender.close();
    connection.close();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }
    }

    I have created QueueConnectionFactory with JNDI jms/ConnectionFactory
    and Queues with JNDI "jms/Q1","jms/Q2"

    Please do reply
    Deepak







  4. Re: Problem Running standalone JMS program

    Hi Brian,
    Thanks for the reply,

    I couldnt go about sending a msg to a queue using thin-client, I checked the provider endpoint it is correct , AppServerip:BootStrapAddress .

    Anyway now i was trying to use Application Client(launchclient tool) to send a msg to a queue. I have created the QueueConnectionFactory and the queue on both server and client using the admin console wizard and clientConfig respectively . But still no luck :-((
    Actually i was wondering how client program knows the info bout the app server , i mean server info through which connectionfactory and queue to look for, coz we dont provide the server info in the client program.( I think coz we mention the server info during the application client installation time , it assumes the server to be that , is this the case ???)

    My code is :


    import com.ibm.etools.service.locator.ServiceLocatorManag er;
    import javax.jms.*;
    import javax.naming.*;
    public class Main
    {

    public static void main(String[] args)
    {
    try
    {
    String messageID = null;
    String outString = "hii";
    String qcfName = "java:comp/env/jms/ConnectionFactory";
    String qnameIn = "java:comp/env/jms/Q1";
    String qnameOut = "java:comp/env/jms/Q2";
    boolean verbose = false;
    QueueSession session = null;
    QueueConnection connection = null;
    Context ctx = null;
    QueueConnectionFactory qcf = null;
    Queue inQueue = null;
    Queue outQueue = null;

    ctx = new InitialContext();
    qcf = (QueueConnectionFactory)ctx.lookup(qcfName); <----- point of Exception
    inQueue = (Queue)ctx.lookup(qnameIn);
    outQueue = (Queue)ctx.lookup(qnameOut);
    connection = qcf.createQueueConnection();
    connection.start();
    boolean transacted = false;
    session = connection.createQueueSession( transacted,
    Session.AUTO_ACKNOWLEDGE);
    QueueSender queueSender = session.createSender(inQueue);
    TextMessage outMessage = session.createTextMessage(outString);
    queueSender.close();
    connection.close();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }
    }

    I have created QueueConnectionFactory with JNDI jms/ConnectionFactory
    and Queues with JNDI "jms/Q1","jms/Q2"

    I am getting the below exception

    C:\Program Files\IBM\WebSphere\AppClient\bin>launchclient "C:\Documents and Settings\Administrator\Desktop\JMSSenderEAR.ear"
    IBM WebSphere Application Server, Release 6.0
    J2EE Application Client Tool
    Copyright IBM Corp., 1997-2004
    WSCL0012I: Processing command line arguments.
    WSCL0013I: Initializing the J2EE Application Client Environment.
    WSCL0220E: An unsuccessful attempt was made to find the resource configuration information for factorylookup.
    WSCL0220E: An unsuccessful attempt was made to find the resource configuration information for quelookup1.
    WSCL0035I: Initialization of the J2EE Application Client Environment has completed.
    WSCL0014I: Invoking the Application Client class Main
    javax.naming.NameNotFoundException: Name comp/env/jms not found in context "java:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInt ernal(NameSpace.java:1716)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal( NameSpace.java:1062)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpac e.java:985)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(Ur lContextImpl.java:1263)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:198)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:139)
    at javax.naming.InitialContext.lookup(InitialContext. java:361)
    at Main.main(Main.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:60)
    at java.lang.reflect.Method.invoke(Method.java:391)
    at com.ibm.websphere.client.applicationclient.launchC lient.createContainerAndLaunchApp(launchClient.jav a:64
    9)
    at com.ibm.websphere.client.applicationclient.launchC lient.main(launchClient.java:435)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:60)
    at java.lang.reflect.Method.invoke(Method.java:391)
    at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.ja va:190)

    Please do reply,
    Deepak


  5. Re: Problem Running standalone JMS program

    Hi Deepak,

    Whereas you appeared to previously be getting a successful lookup in JNDI to
    a connection factory, but then the connection factory parameters were
    insufficient to get a connection to a messaging engine, you now seem to be
    failing to even find the connection factory in JNDI. So your application is
    not even getting as far as any messaging or JMS code. I don't know JNDI
    configuration in WebSphere Application Server well enough to help, I'm
    afraid. I suggest you post this latest problem to
    ibm.software.websphere.application-server, where it is more likely that
    people will know more to be able to help.

    Brian

    wrote in message
    news:1939866554.1134312343601.JavaMail.wassrvr@lts gwas007.sby.ibm.com...
    > Hi Brian,
    > Thanks for the reply,
    >
    > I couldnt go about sending a msg to a queue using thin-client, I checked

    the provider endpoint it is correct , AppServerip:BootStrapAddress .
    >
    > Anyway now i was trying to use Application Client(launchclient tool) to

    send a msg to a queue. I have created the QueueConnectionFactory and the
    queue on both server and client using the admin console wizard and
    clientConfig respectively . But still no luck :-((
    > Actually i was wondering how client program knows the info bout the app

    server , i mean server info through which connectionfactory and queue to
    look for, coz we dont provide the server info in the client program.( I
    think coz we mention the server info during the application client
    installation time , it assumes the server to be that , is this the case ???)
    >
    > My code is :
    >
    >
    > import com.ibm.etools.service.locator.ServiceLocatorManag er;
    > import javax.jms.*;
    > import javax.naming.*;
    > public class Main
    > {
    >
    > public static void main(String[] args)
    > {
    > try
    > {
    > String messageID = null;
    > String outString = "hii";
    > String qcfName = "java:comp/env/jms/ConnectionFactory";
    > String qnameIn = "java:comp/env/jms/Q1";
    > String qnameOut = "java:comp/env/jms/Q2";
    > boolean verbose = false;
    > QueueSession session = null;
    > QueueConnection connection = null;
    > Context ctx = null;
    > QueueConnectionFactory qcf = null;
    > Queue inQueue = null;
    > Queue outQueue = null;
    >
    > ctx = new InitialContext();
    > qcf = (QueueConnectionFactory)ctx.lookup(qcfName); <----- point of

    Exception
    > inQueue = (Queue)ctx.lookup(qnameIn);
    > outQueue = (Queue)ctx.lookup(qnameOut);
    > connection = qcf.createQueueConnection();
    > connection.start();
    > boolean transacted = false;
    > session = connection.createQueueSession( transacted,
    > Session.AUTO_ACKNOWLEDGE);
    > QueueSender queueSender = session.createSender(inQueue);
    > TextMessage outMessage = session.createTextMessage(outString);
    > queueSender.close();
    > connection.close();
    > }
    > catch(Exception e)
    > {
    > e.printStackTrace();
    > }
    > }
    > }
    >
    > I have created QueueConnectionFactory with JNDI jms/ConnectionFactory
    > and Queues with JNDI "jms/Q1","jms/Q2"
    >
    > I am getting the below exception
    >
    > C:\Program Files\IBM\WebSphere\AppClient\bin>launchclient "C:\Documents

    and Settings\Administrator\Desktop\JMSSenderEAR.ear"
    > IBM WebSphere Application Server, Release 6.0
    > J2EE Application Client Tool
    > Copyright IBM Corp., 1997-2004
    > WSCL0012I: Processing command line arguments.
    > WSCL0013I: Initializing the J2EE Application Client Environment.
    > WSCL0220E: An unsuccessful attempt was made to find the resource

    configuration information for factorylookup.
    > WSCL0220E: An unsuccessful attempt was made to find the resource

    configuration information for quelookup1.
    > WSCL0035I: Initialization of the J2EE Application Client Environment has

    completed.
    > WSCL0014I: Invoking the Application Client class Main
    > javax.naming.NameNotFoundException: Name comp/env/jms not found in context

    "java:".
    > at

    com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInt ernal(NameSpace.java:1716)
    > at

    com.ibm.ws.naming.ipbase.NameSpace.lookupInternal( NameSpace.java:1062)
    > at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpac e.java:985)
    > at

    com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(Ur lContextImpl.java:1263)
    > at

    com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:198
    )
    > at

    com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:139
    )
    > at javax.naming.InitialContext.lookup(InitialContext. java:361)
    > at Main.main(Main.java:26)
    > at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    > at

    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85
    )
    > at

    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58
    )
    > at

    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl
    ..java:60)
    > at java.lang.reflect.Method.invoke(Method.java:391)
    > at

    com.ibm.websphere.client.applicationclient.launchC lient.createContainerAndLa
    unchApp(launchClient.java:64
    > 9)
    > at

    com.ibm.websphere.client.applicationclient.launchC lient.main(launchClient.ja
    va:435)
    > at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    > at

    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85
    )
    > at

    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58
    )
    > at

    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl
    ..java:60)
    > at java.lang.reflect.Method.invoke(Method.java:391)
    > at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.ja va:190)
    >
    > Please do reply,
    > Deepak
    >




  6. Re: Problem Running standalone JMS program


    Yes Brian ur right i am not even getting the JNDI lookup now,I will post it application server forum and hope for the best.

    deepak

+ Reply to Thread