PetStore 1.3.1 Admin Client
ehenne Jan 8, 2003 9:55 AMThis topic is a successor to "Running PetStore 1.3 on JBoss 3.0" (http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ where I explained how to run the core of the Petstore example. Here I want to explain the changes needed to run the rest of Petstore.
1. PetStore deployment structure
Before building the other Petstore applications we have to take a look at the overall structure of Petstore. The following gives an overview of the deployment structure. I have only listed the packages and enterprise beans, elements with multiple occurrences are marked bold and their content is only listed once:
petstore.ear
....asyncsender-ejb.jar
........AsyncSenderEJB
....asyncsender-ejb-client.jar
....cart-ejb.jar
....cart-ejb-client.jar
....catalog-ejb.jar
....catalog-ejb-client.jar
....customer-ejb.jar
........AccountEJB
........AddressEJB
........ContactInfoEJB
........CreditCardEJB
........CustomerEJB
........ProfileEJB
....customer-ejb-client.jar
....petstore.war
....petstore-ejb.jar
....po-ejb-client.jar
....servicelocator.jar
....signon-ejb.jar
....signon-ejb-client.jar
....tracer.jar
....uidgen-ejb.jar
....uidgen-ejb-client.jar
....xmldocuments.jar
opc.ear
....mailer-ejb.jar
........MailerMDB
....mailer-ejb-client.jar
........MailerMDB
....opc.war
....opc-ejb.jar
........OPCAdminFacadeEJB
........InvoiceMDB
........MailCompletedOrderMDB
........MailInvoiceMDB
........MailOrderApprovalMDB
........OrderApprovalMDB
....po-ejb.jar
........AddressEJB
........CreditCardEJB
........ContactInfoEJB
........LineItemEJB
........PurchaseOrderEJB
....po-ejb-client.jar
....processmanager-ejb.jar
........ProcessManagerEJB
........ManagerEJB
....processmanager-ejb-client.jar
........ManagerEJB
....servicelocator.jar
....xmldocuments.jar
petstoreadmin.ear
....asyncsender-ejb.jar
....asyncsender-ejb-client.jar
....opc-ejb.jar
....opc-ejb-client.jar
........OPCAdminFacadeEJB
........MailCompletedOrderMDB
........MailInvoiceMDB
........MailOrderApprovalMDB
....petstoreadmin.war
........AdminApp.jar
........crimson.jar
........jaxp.jar
........asyncsender-ejb-client.jar
........opc-client-ejb.jar
........servicelocator.jar
........xmldocuments.jar
....xmldocuments.jar
supplier.ear
....processmanager-ejb.jar
....processmanager-ejb-client.jar
....servicelocator.jar
....supplier.war
........supplierpo-ejb-client.jar
........processmanager-ejb-client.jar
........servicelocator.jar
........xmldocuments.jar
........InventoryEJB
........SupplierOrderMDB
....supplier-ejb.jar
........OrderFulfillmentFacadeEJB
........InventoryEJB
........SupplierOrderMDB
....supplierpo-ejb.jar
........AddressEJB
........ContactInfoEJB
........LineItemEJB
........SupplierOrderEJB
....supplierpo-ejb-client.jar
....xmldocuments.jar
Now let us build and deploy opc.ear.
2. Naming conflicts
From the structure you can see that most of the EJBs in po-ejb.jar are also used in other applications. So we have to give them unique JNDI names in src\components\purchaseorder\src\jboss.xml. Because we use the local interfaces their JNDI names have to be defined via <local-jndi-name>. I have used the original names from src\apps\opc\src\sun-j2ee-ri.xml:
<enterprise-beans>
<ejb-name>AddressEJB</ejb-name>
<local-jndi-name>ejb/opc/po/Address</local-jndi-name>
<ejb-name>ContactInfoEJB</ejb-name>
<local-jndi-name>ejb/opc/po/ContactInfo</local-jndi-name>
<ejb-name>LineItemEJB</ejb-name>
<local-jndi-name>ejb/opc/po/LineItem</local-jndi-name>
<ejb-name>CreditCardEJB</ejb-name>
<local-jndi-name>ejb/opc/po/CreditCard</local-jndi-name>
</enterprise-beans>
To include jboss.xml in the build process we need also an additional entry in the "ejbjar" target of src\components\purchaseorder\src\build.xml:
3. Queues
The message queues for opc have to be defined in src\apps\opc\src\jboss.xml. Here is the start of it together with the first MDB declarations:
<enterprise-beans>
<ejb-name>OPCAdminFacadeEJB</ejb-name>
<jndi-name>ejb/opc/opc/OPCAdminFacadeEJBRemote</jndi-name>
<message-driven>
<ejb-name>PurchaseOrderMDB</ejb-name>
<!--jndi-name>jms/opc/OrderQueue</jndi-name-->
<destination-jndi-name>queue/A</destination-jndi-name>
<resource-ref>
<res-ref-name>jms/QueueConnectionFactory</res-ref-name>
<jndi-name>ConnectionFactory</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>url/EntityCatalogURL</res-ref-name>
<res-url>http://localhost:8080/opc/EntityCatalog.jsp</res-url>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name>jms/OrderApprovalQueue</resource-env-ref-name>
<!--jndi-name>jms/opc/OrderApprovalQueue</jndi-name-->
<jndi-name>queue/B</jndi-name>
</resource-env-ref>
</message-driven>
...
As you can see I am reusing the existing queues (queue/A, queue/B, etc.) but you could also define new ones inside jbossmq-destinations-service.xml. You have only to map the message sender (from <resource-env-ref>) to its MDB receiver (in <destination-jndi-name>). The above jboss declarations contain additional entries for QueueConnectionFactory and for an URL reference.
We need similar declarations for the other MDBs, look in src\apps\opc\src\sun-j2ee-ri.xml for the corresponding sun declarations.
Again we need the entry for jboss in src\apps\opc\src\build.xml:
4. Problem with createQueueSession
To let the queues work we have to make a small change in the source code. The value of the first parameter of
QueueConnection.createQueueSession (boolean transacted, int acknowledgeMode)
should be ignored according to EJB 2.0 but setting it to true will in Jboss just silently ignore all sent messages. So we have to change its value to false in the files ...\AsyncSenderEJB.java and ...\opc\transitions\QueueHelper.java
AsyncSenderEJB is in petstore.ear, so you have to rebuild it.