This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
EJB and other Java EE Technologies
Author
RequiresNew timeout CMP Sequence Pattern
Philip Rowley
Greenhorn
Joined: Jul 18, 2007
Posts: 4
posted
Jul 26, 2007 09:28:00
0
I have been following Floyd Marinescu's
EJB
Design Patters
pdf
from theserverside.com
I have been trying out his Sequence design
pattern
, the only problem I seem to have is that the transaction times out for my Sequence Entity bean.
If I remove the container-transaction(s) below it works, but is not clustersafe.
RequiresNew - Sequence Entity
Required - Sequence Session
Excerp
<assembly-descriptor id="AssemblyDescriptor_1184927679390"> <container-transaction> <method> <ejb-name>Sequence</ejb-name> <method-intf>Local</method-intf> <method-name>getNextKeyAfterIncrementingBy</method-name> <method-params> <method-param>int</method-param> </method-params> </method> <trans-attribute>RequiresNew</trans-attribute> </container-transaction> <container-transaction> <method> <ejb-name>SequenceSession</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor>
Full
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee <a href="http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">" target="_blank" rel="nofollow">http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"></a> <display-name> StockEJB</display-name> <enterprise-beans> <session id="StockList"> <ejb-name>StockList</ejb-name> <home>ejbs.StockListHome</home> <remote>ejbs.StockList</remote> <local-home>ejbs.StockListLocalHome</local-home> <local>ejbs.StockListLocal</local> <ejb-class>ejbs.StockListBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <ejb-local-ref id="EJBLocalRef_1184929700531"> <description> </description> <ejb-ref-name>ejb/StockList</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>ejbs.StockListLocalHome</local-home> <local>ejbs.StockListLocal</local> <ejb-link>StockList</ejb-link> </ejb-local-ref> <ejb-local-ref id="EJBLocalRef_1184933704031"> <description> </description> <ejb-ref-name>ejb/Stock</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>ejbs.StockLocalHome</local-home> <local>ejbs.StockLocal</local> <ejb-link>Stock</ejb-link> </ejb-local-ref> </session> <entity id="Stock"> <ejb-name>Stock</ejb-name> <local-home>ejbs.StockLocalHome</local-home> <local>ejbs.StockLocal</local> <ejb-class>ejbs.StockBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>Stock</abstract-schema-name> <cmp-field id="CMPAttribute_1184927689890"> <field-name>id</field-name> </cmp-field> <cmp-field id="CMPAttribute_1184927689921"> <field-name>sname</field-name> </cmp-field> <primkey-field>id</primkey-field> <ejb-local-ref id="EJBLocalRef_1184928280156"> <description> </description> <ejb-ref-name>ejb/Stock</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>ejbs.StockLocalHome</local-home> <local>ejbs.StockLocal</local> <ejb-link>Stock</ejb-link> </ejb-local-ref> <ejb-local-ref id="EJBLocalRef_1184933825781"> <description> </description> <ejb-ref-name>ejb/StockList</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>ejbs.StockListLocalHome</local-home> <local>ejbs.StockListLocal</local> <ejb-link>StockList</ejb-link> </ejb-local-ref> <ejb-local-ref id="EJBLocalRef_1185367174623"> <description> </description> <ejb-ref-name>ejb/SequenceSession</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>ejbseq.SequenceSessionLocalHome</local-home> <local>ejbseq.SequenceSessionLocal</local> <ejb-link>SequenceSession</ejb-link> </ejb-local-ref> </entity> <session id="StockCount"> <ejb-name>StockCount</ejb-name> <home>ejbs.StockCountHome</home> <remote>ejbs.StockCount</remote> <local-home>ejbs.StockCountLocalHome</local-home> <local>ejbs.StockCountLocal</local> <ejb-class>ejbs.StockCountBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <ejb-local-ref id="EJBLocalRef_1184931446359"> <description> </description> <ejb-ref-name>ejb/StockCount</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>ejbs.StockCountLocalHome</local-home> <local>ejbs.StockCountLocal</local> <ejb-link>StockCount</ejb-link> </ejb-local-ref> <ejb-local-ref id="EJBLocalRef_1184932440015"> <description> </description> <ejb-ref-name>ejb/StockList</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>ejbs.StockListLocalHome</local-home> <local>ejbs.StockListLocal</local> <ejb-link>StockList</ejb-link> </ejb-local-ref> </session> <session id="SequenceSession"> <ejb-name>SequenceSession</ejb-name> <local-home>ejbseq.SequenceSessionLocalHome</local-home> <local>ejbseq.SequenceSessionLocal</local> <ejb-class>ejbseq.SequenceSessionBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <env-entry> <description> Number of times to get new sequence range</description> <env-entry-name>retryCount</env-entry-name> <env-entry-type>java.lang.Integer</env-entry-type> <env-entry-value>5</env-entry-value> </env-entry> <env-entry> <description> Size of sequence block to get from db</description> <env-entry-name>blockSize</env-entry-name> <env-entry-type>java.lang.Integer</env-entry-type> <env-entry-value>10</env-entry-value> </env-entry> <ejb-local-ref id="EJBLocalRef_1185367321326"> <description> </description> <ejb-ref-name>ejb/Sequence</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>ejbseq.SequenceLocalHome</local-home> <local>ejbseq.SequenceLocal</local> <ejb-link>Sequence</ejb-link> </ejb-local-ref> </session> <entity id="Sequence"> <ejb-name>Sequence</ejb-name> <local-home>ejbseq.SequenceLocalHome</local-home> <local>ejbseq.SequenceLocal</local> <ejb-class>ejbseq.SequenceBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>Sequence</abstract-schema-name> <cmp-field id="CMPAttribute_1185367420623"> <field-name>index</field-name> </cmp-field> <cmp-field id="CMPAttribute_1185367420639"> <field-name>tablename</field-name> </cmp-field> <primkey-field>tablename</primkey-field> </entity> </enterprise-beans> <assembly-descriptor id="AssemblyDescriptor_1184927679390"> <container-transaction> <method> <ejb-name>Sequence</ejb-name> <method-intf>Local</method-intf> <method-name>getNextKeyAfterIncrementingBy</method-name> <method-params> <method-param>int</method-param> </method-params> </method> <trans-attribute>RequiresNew</trans-attribute> </container-transaction> <container-transaction> <method> <ejb-name>SequenceSession</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar>
Is there more I need to set in ejb-jar.xml?
I am using
IDE - IBM RAD 7
AS - WebSphere 6.1
DB - Derby 10.1
Thanks
Phil
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: RequiresNew timeout CMP Sequence Pattern
Similar Threads
Accessing local entity bean using Session bean
WebSphere V5 CMP create problem
Crisis in making CMP2.0 relationship
Deployment Error : Class not found
EJB Query Error
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter