0. Prerequisite
Actually this sample is postponed, please reference to prerequisites of sample03 and 04.
1. Customize code in chapter2
$ cd $HOME/student/ejbAction
$ cd chapter2
$ for i in `find * -name "*.orig"`; do j=`expr $i :'\(.*\).orig'`; echo diff -u $i $j; diff -ub $i $j; echo; echo; done
diff -u build.xml.orig build.xml
...
<classpath>
<pathelement location="${lib.dir}/${cli.name}.jar"/>
<pathelementl ocation="${bld.ejb.dir}"/>
- <pathelement location="${WLS_HOME}/server/lib/wlclient.jar"/>
+ <pathelement location="${WLS_HOME}/server/lib/weblogic.jar"/>
</classpath>
...
<classpath>
<pathelement location="${lib.dir}/${cli.name}.jar"/>
<pathelement location="${bld.ejb.dir}"/>
- <pathelement location="${WLS_HOME}/server/lib/wlclient.jar"/>
+ <pathelement location="${WLS_HOME}/server/lib/weblogic.jar"/>
</classpath>
diff -u etc/persistence.xml.orig etc/persistence.xml
...
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="actionBazaar">
-<jta-data-source>ActionBazaarDS</jta-data-source>
-<properties>
- <property name="kodo.jdbc.SynchronizeMappings"value="buildSchema"/>
-</properties>
+ <jta-data-source>examples-dataSource-demoXAPool</jta-data-source>
</persistence>
diff -u etc/jndi.properties.orig etc/jndi.properties
...
#Set required appropriate for your environment
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
-java.naming.provider.url=t3://localhost:7001
+java.naming.provider.url=t3://localhost:8001
diff -u src/ejb/bean/ejb3inaction/example/buslogic/PlaceOrderBean.java.orig src/ejb/bean/ejb3inaction/example/buslogic/PlaceOrderBean.java
...
@Stateful(mappedName = "PlaceOrder")
public class PlaceOrderBean implements PlaceOrder {
- @Resource(name = "jms/QueueConnectionFactory",mappedName="weblogic.examples.ejb30.QueueConnectionFactory")
+ @Resource(name = "weblogic.examples.ejb30.QueueConnectionFactory",mappedName="weblogic.examples.ejb30.QueueConnectionFactory")
private QueueConnectionFactory connectionFactory;
$ cat sql/tables.sql # besides, need to a db table
drop table BIDS;
create table BIDS (
BID_ID BIGINT primary key,
BID_DATE DATE,
BID_STATUS VARCHAR(20),
BID_PRICE FLOAT,
BID_ITEM_ID BIGINT,
BID_BIDDER VARCHAR(45)
);
2. Build, deploy and run
$ cd $ORACLE_HOME/wlserver/samples/server
$ . ./setExamplesEnv.sh # set environment variables
$ cd $HOME/student/ejbAction/chapter4
$ ant undeploy # if need
$ ant clean
$ ant db-setup # create db tables
$ ant # build and deploy
$ ant run # run the stateless EJB with JPA entity sample
run:
[echo] Executing client class
[java] Bid Successful, BidId Received is:251
In console, we can see following messages:
Adding bid, bidder ID=npanda, item ID=100, bid amount=20000.4.
Your bid your item id:100was successful
Your bid id is: 251
The result can be observed from ij tool as well:
$ ../ij.sh
ij version 10.11
CONNECTION0* - jdbc:derby://localhost:1527/examples
* = current connection
ij> select * from BIDS;
BID_ID |BID_DATE |BID_STATUS |BID_PRICE |BID_ITEM_ID |BID_BIDDER
------------------------------------------------------------------------------------------------------------------------------
251 |NULL |NULL |20000.4 |100 |npanda
1 row selected
ij> disconnect;
ij> exit;
$ ant run-sfsb # run the stateful EJB with MDB sample
run-sfsb:
[echo] Executing client class
[java] Exercising PlaceOrder EJB...
[java] Order confirmation number: 1000
In console, we can see following messages:
Billing Completed by MDB ..
A/c No:123456789 charged..