Archive for July, 2009

14
Jul
09

Coming clean

I have been toying with this idea for while now – to finally, after 8 years or so, tell my parents that I am an Atheist. Those 8 years consisted of a handful of occasions of me actually going to Church when I was at home and lying about going to Church when I wasn’t.  I didn’t like the lying part at all.

I have tried to imagine the actual conversation and thanks to my ever optimistic/paranoid imagination made up various scenarios of how they would react – from kicking me out of the house to telling me that they secretly were the same too.

The actual conversation was way less entertaining. My dad had this disappointed look on his face and gave me that empty threat I have heard one too many times: “You will learn someday”. My mom couldn’t/wouldn’t really grasp this and, from what I could make out, seemed to think that I shifted my religion to something else. A few more words cleared that up.

Some minutes later, after a few calm words and an awkward long silence, the topic shifted and all was back to normal – and it stayed like that. Except for the extra minutes my mom prays to compensate for my lack of prayer and a little more prodding for information.

It makes me wonder, why I never told them anything earlier. Then again, if I would have told them earlier (as a student) they might not have taken me seriously.

Anyways, here is the Disclaimer: Kids, don’t try this at home. (Unless you are fairly certain of the outcome or can handle the consequences). On second thought, go ahead.

02
Jul
09

Writing a standalone JMS Java Client to connect to Websphere MQ 6.0 via Websphere Application Server 6.1

Somehow, when I tried to write a standalone client I kept coming across the following exception
java.lang.ClassCastException: javax.naming.Reference incompatible with javax.jms.ConnectionFactory “.

I followed intructions from here to setup the Queue, after which I created a simple java client to post a message to the Queue:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, “com.ibm.websphere.naming.WsnInitialContextFactory”);
env.put(Context.PROVIDER_URL, “iiop://localhost:2809″);

Context jndiContext = null;
try {
jndiContext = new InitialContext(env);
} catch (NamingException e) {

System.out.println(“Could not create JNDI API context: ” + e.toString());
System.exit(1);
}

ConnectionFactory connectionFactory = (ConnectionFactory)  jndiContext.lookup(“jms/JMSExampleConnectionFactory”);
Connection qConn = connectionFactory.createConnection();
Session qSession = qConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue q = (Queue) jndiContext.lookup(“jms/JMSExampleQueue”);

MessageProducer producer = qSession.createProducer(q);
TextMessage message = qSession.createTextMessage();
message.setText(“test message”);
producer.send(message);

producer.close();
qSession.close();
qConn.close();

Even after switching to the IBM JRE and adding the relevant Jars (as suggested in most places.) the program kept throwing the ClassCast Exception. Just in case you are wondering, the relevant Jars ( found in <Websphere Installation Path>/runtimes/ and <Websphere Installation Path>/lib/WMQ/java/lib/ ) are:

com.ibm.mq.jar
com.ibm.mqjms.jar
com.ibm.ws.webservices.thinclient_6.1.0.jar
dhbcore.jar
ws_runtime.jar

After googling and reading through lot of forum threads I finally stumbled on the solution. To resolve this you also need to add added the <Websphere Installation Path>/plugins/com.ibm.ws.runtime_6.1.0.jar to the classpath.  Seems simple enough, but it took me ages to find. Hence the post.




Blog Stats

  • 38,666 pings

Pages

 

July 2009
M T W T F S S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031