How to run JMS in J2ee 1.4

Hai

i am working with jms now. i sent both synchronized & asynchronized using j2ee 1.3 it is working properly but in j2ee 1.4 it seems to be different. I need to run my application in same way as in j2ee 1.3 that is i want it to run throughjava instead ofappclient how to do it please tell me.

Thanks in advance

[350 byte] By [prasadmcaa] at [2007-10-2 23:34:32]
# 1

Hi Prasad,

To run the JMS part, u required to include the .jar file

jms.jar

javax.jms.jar

j2ee.jar

This 3 .jar to be presence in the CLASSPATH

and look into the j2ee1.4 Java doc there u will get few methods are introduced, it's self explained one.

let me know if still is not running......

PrasannA

PrasannA@javaa at 2007-7-14 16:16:27 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
thanks for your replywhere could i find javax.jms.jar file
prasadmcaa at 2007-7-14 16:16:27 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

you will get the jar files for jms.jar and javax.jms.jar

download and put it in the classpath

http://java.sun.com/products/jms/docs.html

use the below heding - click download

Download the version 1.1 API Documentation, Jar and Source

hope It could help u

Prasanna

PrasannA@javaa at 2007-7-14 16:16:28 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Thanks prasannabut before that take a look @ this http://forum.java.sun.com/thread.jspa?threadID=749800&tstart=0
prasadmcaa at 2007-7-14 16:16:28 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Hi,

to run in j2ee1.4, u must create a initial context with the below properties

refer the sample snippet,

try

{

Properties prop = new Properties();

prop.put( Context.INITIAL_CONTEXT_FACTORY,

"weblogic.jndi.ContextFactory" );

prop.put( Context.PROVIDER_URL, url );

prop.put( Context.SECURITY_PRINCIPAL, "system" );

prop.put( Context.SECURITY_CREDENTIALS, "weblogic" );

context = new InitialContext( prop );

System.out.println( "Initial Context created..." );

connectionFactory = ( QueueConnectionFactory )context.lookup(

"weblogic.jms.MDBConnectionFactory" );

connection = connectionFactory.createQueueConnection();

connection.start();

session = connection.createQueueSession(

false, Session.AUTO_ACKNOWLEDGE );

// end properties initialization

// start sendmessage to queue

Queue queue = ( Queue )context.lookup( destination );

Topic replyToTopic = ( Topic )context.lookup( replyTo );

QueueSender sender = session.createSender( queue );

TextMessage message = session.createTextMessage( xmlMessage );

message.setJMSReplyTo( replyToTopic );

sender.send( message );

}

catch(NameNotFoundException nnfe)

{

System.out.println("Problem in finding Queue Details while sending XML Request to server:\n"+nnfe.getMessage());

errorFlag=true;

}

u have to do above changes to run in J2EE 1.4

Hope it could help u, If still u find problem, let me know where exactly u struck

With cheers

Prasanna

PrasannA@javaa at 2007-7-14 16:16:28 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6
Thanks for your reply prasannait seems you have given properties for Weblogic but what actually i need is for J2EE 1.4 how to set it plz tell me Thank u
prasadmcaa at 2007-7-14 16:16:28 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7

Hi,

see the below commented lines

prop.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.ContextFactory" ); // Here the initial context is weblogic specific, for J2EE also it will have it's own factory name - find out & place it

prop.put( Context.PROVIDER_URL, url ); // here you have to give the URL like http://localhost:port id....

prop.put( Context.SECURITY_PRINCIPAL, "system" ); // user Name

prop.put( Context.SECURITY_CREDENTIALS, "weblogic" ); // password

Hope now you understand, what you have to change,

in the Initial Context Factory - you have to give the ContextFactory name which is specific for server. find out what it is and give it there

Try with this, let me know if it's not working...

With Cheers,

PrasannA

PrasannA@javaa at 2007-7-14 16:16:28 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 8
i cannot find ContextFactory for j2ee where could i find it?
prasadmcaa at 2007-7-14 16:16:28 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...