| Summary: | MessageDriven bean EJB 3 wizard generates non-portable code | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] WTP EJB Tools | Reporter: | Max Rydahl Andersen <manderse> | ||||||
| Component: | jst.ejb | Assignee: | Kaloyan Raev <kaloyan> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Kaloyan Raev <kaloyan> | ||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | cbridgha, ccc, stryker | ||||||
| Version: | unspecified | Flags: | kaloyan:
review?
(stryker) |
||||||
| Target Milestone: | 3.4.2 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Related JBoss jira issues: https://issues.jboss.org/browse/JBIDE-8530 Just to document this is what the javadoc spec actually says: http://download.oracle.com/javaee/5/api/javax/ejb/MessageDriven.html "A product specific name(e.g. global JNDI name of a queue) that this message-driven bean should be mapped to. Application servers are not required to support any particular form or type of mapped name, nor the ability to use mapped names. The mapped name is product-dependent and often installation-dependent. No use of a mapped name is portable. " notice the "No use of a mapped name is portable" phrase. Created attachment 201597 [details]
Ensuring a new property is added
Could you all please point out where in the spec "destination" and "destinationType" are defined?
The attached patch adds the destination to the config without removing the mapped name. It could be argued my impl is shit, but it's the best I could do without understanding more about the surrounding infrastructure of the tools.
Pinging the QA lead To be clear, my patch performs the following:
@MessageDriven(
activationConfig = { @ActivationConfigProperty(
propertyName = "destinationType", propertyValue =
"javax.jms.Queue"
),@ActivationConfigProperty(
propertyName = "destination", propertyValue = "queue"
) },
mappedName = "queue")
public class MyMdb implements MessageListener {
The reason my patch does this is in case other tools depend on the mappedName = "queue" attribute that has been there forever.
Rob, I am reviewing it right now. Created attachment 201722 [details]
Reworked patch - fix done in the JET template and model
The original patch of Rob fixes the problem in the code generated by the JET engine. This patch fixes the problem also in the JET template and model.
Rob, could you confirm that the patch I've attached does the same as you original patch? BTW, I've also searched in the EJB spec, but could not find the "destination" property specified. It would be good to have a reference to the relevant chapter in the spec. Rob, have you got time to review the re-worked patch? I will have time this week. I needed to wait get Max's approval and spec reference, and he's been on vacation. The Indigo SR1 train passed away. Moving for SR2. Rob, Max, do you still need this for the Indigo stream? If yes, then please review the last patch. The train has passed for Indigo - how about Juno ? > It would be good to have a reference to the relevant chapter in the spec.
You'll want to lookat b.2.1.1 of the j2ee connector specification, which reads as follows:
destination
In general, a destination is a logical link between a message producer and a
consumer. A message producer produces messages addressed to a destination, and a
message consumer consumes messages from a chosen destination.
A destination could be represented by a JMS provider in different ways. For example, it could be encapsulated as textual data (this may be specified by endpoint developer or assembler in the endpoint deployment descriptor) or as a private object available only at deployment time. Hence, it may not always be specified in an endpoint deployment descriptor (since deployment descriptor entries contain textual data only).
However, during endpoint deployment JMS ActivationSpec JavaBean requires a value for the destination property. While configuring the JMS ActivationSpec JavaBean, the endpoint deployer must provide a value for this property (if it is not already present in the endpoint deployment descriptor).
It is recommended that destination be specified by a JMS resource adapter provider as a property on the ActivationSpec JavaBean that requires a value. This can be specified in the JMS resource adapter deployment descriptor.
The destination property value may also be an object that implements the javax.jms.Destination interface. In such a case, the resource adapter should provide an administered object that implements the javax.jms.Destination interface.
And B 2.1.2 that talks about Destinationtype property. Rob, Max, thank you for the references. Assuming you have reviewed the reworked patch I attached some time ago, I will apply it for Juno SR1. Did we apply this patch? Thanks for the reminder Chuck! Unfortunately, I did not. I waited for the Git migration to complete and then simply forgot. I will make sure to commit this change early for Juno SR2. Hey Kaloyan: Just a ping reminder to push this in to master and sr2 if possible ;) Patch pushed to master: http://git.eclipse.org/c/ejb/webtools.ejb.git/commit/?id=d01e8201d9bb0b67c10353edba72d87b323bf97c and to R3_4_maintenance: http://git.eclipse.org/c/ejb/webtools.ejb.git/commit/?h=R3_4_maintenance&id=a7795dbcf6f80c31e9a33a4a98523b1d11edb4d4 Hopefully I updated the map files correctly and the patch will be included in the next build. The changes should be included in this build: http://build.eclipse.org/webtools/committers/wtp4x-R3.4.2-M/20121004182514/M-3.4.2-20121004182514/ |
Build Identifier: Indigo/Helios probably also Ganymede The code generated by MessageDriven bean wizard is generating code that uses the non-portable mappedName attribute. It should use the standardized ActivationConfig property instead. Reproducible: Always Steps to Reproduce: 1. Create EJB3 Project 2. Run 'EJB/Message Driven Bean (EJB3.x) wizard 3. Fill, package name, class name, check JMS, select 'Queue' and enter 'queue' to be destination name 4. Finish Current result: @MessageDriven( activationConfig = { @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue" ) }, mappedName = "queue") public class MyMdb implements MessageListener { This will fail to deploy on JBoss (and possibly others too) since the mappedName is *undefined* in the spec it is ignored. A better and more portable result would be: @MessageDriven( activationConfig = { @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue" ),@ActivationConfigProperty( propertyName = "destination", propertyValue = "queue" ) }) public class MyMdb implements MessageListener { This should work across most app servers since the destination and destionType attribute is *defined* which is not the case for mappedName.