Post Subject : Tutorial on J2EE using JBOSS-4.x, Eclipse-3.x, Lomboz-3.x and 
PostgreSQL-8.x on Windows XP

Ref. 1 : Tutorial for building J2EE Applications using JBOSS and ECLIPSE
         http://www.tusc.com.au/tutorial/html/chap7.html (Chapter 7 : Message 
Driven Bean, Exercise)

Ref. 2 : Tutorial on J2EE using JBOSS, ECLIPSE and Lomboz (Forum on Ref. 1)
         http://www.jboss.org/index.html?module=bb&op=viewtopic&t=36910

Ref. 3 : Environment in use ;
- Windows XP SP2
- J2SDK 1.4.2_08
- Eclipse 3.0.2
- JBoss 4.0.2
- Lomboz 3.0.1 + emf-sdo-runtime-2.0.0
- PostgreSQL 8.0.3 (= DefaultDS)

Followings are some notes on Chapter 7 (MDB, Exercise) in Ref. 1

* The notes cover a creation of DeliverItemsBean.
* Task numbers are based on Ref. 1
* No change has been made to the server definition file 
(jboss402postgres.server) thus far.

Task 1 : Create DeliverItems MDB under package au.com.tusc.mdb
- On creation of "DeliverItemsBean", check some points before proceeding 
further steps.
= make sure the XDoclet section of DeliverItemsBean.java;
   :
  |  * <!-- begin-xdoclet-definition --> * @ejb.bean name="DeliverItems" *     
acknowledge-mode="Auto-acknowledge"
  |  *     destination-type="javax.jms.Queue" *     
subscription-durability="NonDurable" *     transaction-type="Container"
  |  *
  |    :
Task 2 : Create an Immutable Value Object named DeliverItem.
: (as per the steps in Ref. 1)
Task 4 : Add class level tags for deployment
 
Task 5 : Deploy the DeliverItems Bean
- generate EJB classes
- fix deployment descriptions, i.e. "ejb-local-ref" and "ejb/"
- start JBoss  with "Run Server" in "Lomboz J2EE View" menu.
- deploy beans
Note : An error on deployment might occur. It states;
00:08:26,344 ERROR [XmlFileLoader] failed to load jboss.xml.  There could be a 
syntax error.
  | org.jboss.deployment.DeploymentException: Error in jboss.xml for Bean 
StoreAccess: ejb-local-ref ejb/StoreAccess found in jboss.xml but not in 
ejb-jar.xml
= If occured, comment out "ejb/StoreAccess" under "session" tag in jboss.xml
= re-deploy
        :
  |          <ejb-local-ref>
  |             <ejb-ref-name>ejb/SupplierLocal</ejb-ref-name>
  |             <jndi-name>SupplierLocal</jndi-name>
  |          </ejb-local-ref>
  | <!--
  |          <ejb-local-ref>
  |             <ejb-ref-name>ejb/StoreAccess</ejb-ref-name>
  |             <jndi-name>StoreAccessBean</jndi-name>
  |          </ejb-local-ref>
  | -->
  |          <resource-ref>
  |             <res-ref-name>jdbc/DefaultDS</res-ref-name>
  |             <jndi-name>java:/DefaultDS</jndi-name>
  |          </resource-ref>
  |         
Task 6 : Create a test client name DeliverMDBClient
: (as per the steps in Ref. 1)
Task 8 : Implement testMDBBean

Task 9 : Run the test client and test the bean
- Messages expected in the console are similar as RequestItemsBean, but they 
probably show an error as below.

"(javax.ejb.EJBException: Store failed; CausedByException is: ERROR: column 
"quantity" is of type integer but expression is of type character varying)"

   :
  | 22:44:08,517 INFO  [STDOUT] Delivering items in store now... :
  | 22:44:08,517 INFO  [STDOUT] Entering ItemBean.fillStock() with quantity 100
  | 22:44:08,517 INFO  [STDOUT] Quantity of items after delivery of items 100
  | 22:44:08,517 INFO  [STDOUT] Leaving ItemBean.fillStock() 
  | 22:44:08,517 INFO  [STDOUT] Entering ItemBean.getItemData() 
  | 22:44:08,517 INFO  [STDOUT] Leaving ItemBean.getItemData() 
  | 22:44:08,517 INFO  [STDOUT] Stock of item after delivery is :{itemID=I4 
supplierID=S1 description=CLOCK quantity=100 price=65.0}
  | 22:44:08,517 INFO  [STDOUT] Entering DeliverItemsBean.onMessage()
  | 22:44:08,533 ERROR [StdServerSession] failed to commit/rollback
  | org.jboss.tm.JBossRollbackException: Unable to commit, 
tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=EX-3000/192, BranchQual=, 
localId=192] status=STATUS_NO_TRANSACTION; - nested throwable: 
(javax.ejb.EJBException: Store failed; CausedByException is:
  |     ERROR: column "quantity" is of type integer but expression is of type 
character varying)
  |     at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:344)
  |     at org.jboss.tm.TxManager.commit(TxManager.java:200)
  |     :
- Modify "jbosscmp-jdbc.xml" under /MyStoreMgr/META-INF in order to avoid the 
error.
= comment out two tags as below.
Note : This is to be considered as a provisional measure only.
           :
  |          <cmp-field>
  |             <field-name>quantity</field-name>
  |             <column-name>QUANTITY</column-name>
  | <!--
  |             <jdbc-type>VARCHAR</jdbc-type>
  |             <sql-type>INTEGER</sql-type>
  | -->
  |          </cmp-field>
  |            :
- re-deploy beans and run the test client. Results are as follows;
Note : not necessary to re-generate classes.
Looking up the factory 
  | Looking up the queue 
  | Creating the connection 
  | Creating the session 
  | Creating the sender 
  | Setting the object in message 
  | Sending the message 
  | Shuting down
  | Done !
or
23:30:27,553 INFO  [STDOUT] Message Driven Bean got message 
org.jboss.mq.SpyObjectMessage {
  | Header { 
  |    jmsDestination  : QUEUE.DelMdbQueue
  |    jmsDeliveryMode : 2
  |    jmsExpiration   : 0
  |    jmsPriority     : 4
  |    jmsMessageID    : ID:31-11193642275381
  |    jmsTimeStamp    : 1119364227538
  |    jmsCorrelationID: null
  |    jmsReplyTo      : null
  |    jmsType         : null
  |    jmsRedelivered  : false
  |    jmsProperties   : {}
  |    jmsPropReadWrite: false
  |    msgReadOnly     : true
  |    producerClientId: ID:31
  | }
  | }
  | 23:30:27,553 INFO  [STDOUT] Entering DeliverItemsBean.onMessage()
  | 23:30:27,585 INFO  [STDOUT] Entering StoreAccessBean.ejbCreate() 
  | 23:30:27,616 INFO  [STDOUT] Leaving StoreAccessBean.ejbCreate() 
  | 23:30:27,632 INFO  [STDOUT] Entering StoreAccessBean
  | 23:30:27,632 INFO  [STDOUT] Leaving StoreAccessBean
  | 23:30:27,632 INFO  [STDOUT] Entering StoreAccessDAOImpl.init()
  | 23:30:27,647 INFO  [STDOUT] Leaving StoreAccessDAOImpl.init()
  | 23:30:27,647 INFO  [STDOUT] Entering StoreAccessDAOImpl.loginUser() 
  | 23:30:27,647 INFO  [STDOUT] Userid is U4
  | 23:30:27,647 INFO  [STDOUT] Leaving StoreAccessDAOImpl.loginUser() 
  | 23:30:27,647 INFO  [STDOUT]  Login is sucessful with U4
  | 23:30:27,647 INFO  [STDOUT]  Entering StoreAccessBean.getSupplierData() 
  | 23:30:27,663 INFO  [STDOUT] Entering SupplierBean.getSupplierData() 
  | 23:30:27,663 INFO  [STDOUT] Leaving SupplierBean.getSupplierData() 
  | 23:30:27,663 INFO  [STDOUT]  Leaving StoreAccessBean.getSupplierData() 
  | 23:30:27,678 INFO  [STDOUT] Delivering items in store now... :
  | 23:30:27,678 INFO  [STDOUT] Entering ItemBean.fillStock() with quantity 100
  | 23:30:27,678 INFO  [STDOUT] Quantity of items after delivery of items 100
  | 23:30:27,678 INFO  [STDOUT] Leaving ItemBean.fillStock() 
  | 23:30:27,678 INFO  [STDOUT] Entering ItemBean.getItemData() 
  | 23:30:27,678 INFO  [STDOUT] Leaving ItemBean.getItemData() 
  | 23:30:27,678 INFO  [STDOUT] Stock of item after delivery is :{itemID=I4 
supplierID=S1 description=CLOCK quantity=100 price=65.0}
  | 23:30:27,678 INFO  [STDOUT] Entering DeliverItemsBean.onMessage()
Also, the results can be checked in the database table using "pgAdmin III".
= select * from item

==> "I4";"S1";"CLOCK";100;65.00


jbosszone



View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3882263#3882263

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3882263


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to