That was an embarrassing slip. Thanks for replying with a straight face :-)
Vivek
Scott "M." Stirling <[EMAIL PROTECTED]>@orionserver.com on 12/27/2000
01:08:08 AM
Please respond to Orion-Interest <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
To: Orion-Interest <[EMAIL PROTECTED]>
cc: (bcc: Vivek Iyer/Chicago SPL/Group)
bcc: Vivek Iyer/Chicago SPL/Group
Subject: Re: basic declarative transaction management
The ejb-name in the assembly-descriptor has to match the ejb-name in the
bean declaration. It doesn't. You have "Product" in one place and
"MyProduct" in the other as the ejb-name. That shouldn't work.
On 26 Dec 2000 23:06:15 -0600, Vivek Iyer wrote:
>
>
> Hi all,
>
> I'm trying to get my understanding/control of declarative transactions in EJB
up
> to speed, and I'm puzzled by the following:
>
> Context: The Product EJB that comes with the ejb/demos with Orion.
>
> Action: I set the value of "trans-attribute" ejb-jar.xml for the "Product"
bean
> that comes with the ejb demos in orion to "Mandatory" for all methods in the
> Product bean (this is just for illustrative purposes).
>
> Expected Result: Since the ProductClient in the ejb demos does _not_
explicitly
> start a UserTransaction, its first invocation of a method on the Product bean
is
> outside of any transaction context, and so should cause a
> TransactionRequiredException to be thrown, should it not?
>
> Actual Result: In fact, after Orion redeploys the Product bean, and the
> ProductClient runs just fine.
>
> Can someone please tell me what I'm missing? I've included the ejb-jar.xml and
> the ProductClient code below. As an aside, if someone could point me to a good
> example system with non-trivial transactions controlled declaratively in
orion,
> I'd be grateful.
>
> Here's the ejb-jar.xml -
> <ejb-jar>
> <description>
> </description>
> <enterprise-beans>
> <entity>
> <description>
> </description>
> <ejb-name>MyProduct</ejb-name>
> <home>ProductHome</home>
> <remote>Product</remote>
> <ejb-class>ProductEJB</ejb-class>
> <primkey-class>java.lang.Integer</primkey-class>
> <reentrant>True</reentrant>
> <persistence-type>Container</persistence-type>
> <cmp-field><field-name>id</field-name></cmp-field>
> <cmp-field><field-name>name</field-name></cmp-field>
> <cmp-field><field-name>description</field-name></cmp-field>
> <cmp-field><field-name>price</field-name></cmp-field>
> <primkey-field>id</primkey-field>
> </entity>
> </enterprise-beans>
> <assembly-descriptor>
> <container-transaction>
> <method>
> <ejb-name>Product</ejb-name>
> <method-name>*</method-name>
> </method>
> <trans-attribute>Mandatory</trans-attribute>
> </container-transaction>
> </assembly-descriptor>
> </ejb-jar>
>
> And here's the relevant code on the ProductClient -
>
> // Create a new Product and narrow the reference.
> Product product = (Product)PortableRemoteObject.narrow(home.create(id),
> Product.class);
> product.setName(name);
> product.setPrice(cost);
>
> Thanks,
>
> Vivek
--
Scott Stirling
West Newton, MA