Friday, 29 May 2009

4-How to setup a JMS queue with also JTA processing

WEBLOGIC JMS queue setup

1- I build the EJB outside the Jdev environment, at C:\JTAdistrib with build.xml
The output goes to C:\ JTAdistrib\ deploy\ JTAdis. jar

2- Then I deployed the EJB with WebLogic Console
Path: C:\ JTAdistrib\ deploy\ JTAdis. Jar

3- Services->Messaging->JMSservers -> Lock-Edit -> new
Name: RegistrarQ
Targets: DefaultServer

4- Services->Messaging->JMSmodules -> Lock-Edit -> new
Name: jms/QCF

Summary of resources

Type…………………..JNDI Name ……….Subdeployment…………………..Targets
jms/QCF…………Connection Factory…ConnectionFactory…Default Targetting……………….DefaultServer

Name: jms/RegistrarQ
Subdeployment: jms/RegistrarQsubdeploy
Destination: RegistrarQ
Monitoring: jms/QCF!jms/RegistrarQ (This is only an output field – I put it here for for checking)
Control: jms/QCF!jms/RegistrarQ (This is only an output field – I put it here for for checking)

Name: jms/QCF
JNDI name: ConnectionFactory
Target: DefaultServer

Do not play with the WebLogic – console parameters. If you need you may change the logging parameters to see more info. But TINTPB’s this example works almost fine specially with the ejb-jar xml files, you just have to make the jms setup work. Please note the sequence of the definitions made with weblogic console. Be carefull about the JNDI names also. Avoid giving the same name to different things, give a unique name to every different thing.

javax.naming.NameNotFoundException: While trying to lookup 'javax.jms.Queue.class' didn't find subcontext 'Queue'.

This error is given when the queue destination has not been made. It looks as if it is a JNDI error but actually the object that the JNDI is supposed to point at does not exist. It gives the same error message to both.

The output to the program is below:

<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Connecting to JDBC data store...>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Begin JTA distributed transaction. . .>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Trying to drop table StudentCourse...>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Table StudentCourse dropped successfully...>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Created new StudentCourse table.>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <A new record is inserted into table StudentCourse. . .>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Connecting to JMS destination...>
<May 28, 2009 10:45:54 PM EEST> <Notice> <Stdout> <BEA-000000> <Notify registration...>
<May 28, 2009 10:45:56 PM EEST> <Notice> <Stdout> <BEA-000000> <Message sent: Student id=1 is enrolled in course=CS310>
<May 28, 2009 10:45:57 PM EEST> <Notice> <Stdout> <BEA-000000> <Committing the transaction. . .>
<May 28, 2009 10:46:09 PM EEST> <Warning> <JMSPool> <BEA-169817> <The JMS connection factory resource ConnectionFactory declared in the EJB "RegistrarMDB" as part of application "JTAdis" does not support XA. It cannot be used inside a transaction context.>

Please note that in order to see this output you must have set up the sensitivity of the defaultserver’s logging to the notice level.

With this example I have completed tinptB ‘s Blog: EJB in 21 Days: which includes almost all aspects of EJB programming. My gratitude goes to him/her. I would be happy if I could contribute just a bit by providing the solutions to all of his open end questions by the way.