5

I'm working on upgrading code from JBoss 5.1 to JBoss 7.1 and it fails if these methods are not implemented explicitly in the resource adapters. I understand the concept of each, and know about the contract between the two. I'm not asking about how to implement them or what they mean. I'm asking specifically why they MUST be implemented for Java EE 6 code (in this case JBoss AS 7.1).

Is there a good reason to put a lot of thought into them or is it sufficient to simply have:

boolean equals(Object obj) { return super.equals(obj) ; }
int hashCode() { return super.hashCode() ; }
Justin K
  • 53
  • 4
  • Where do you see that those are required? – Matt Ball Sep 10 '12 at 20:53
  • On startup. Sorry, first time post, hit enter when typing the tags and it posted the question. Just edited. – Justin K Sep 10 '12 at 20:58
  • Interesting, there seem to be plenty of Google hits for this issue (`"A ResourceAdapter must implement a "public boolean equals(Object)" method."`) but no actual explanations _why_ this is required. – Matt Ball Sep 10 '12 at 21:01
  • I assume that due to passivation, serialization, proxying, and other JEE jiggery-pokery, it's required to prevent two instance of the 'same' object appearing not to be equal. But I can't find a link. – artbristol Oct 19 '12 at 08:27

1 Answers1

1

I think this is because of following

checkout ManagedConnectionFactory here.

see this is an interface and has equals() and hashCode() methods. So Basic java, the first concrete class that implements an interface must define all methods of the interface. Which your resource adapter must be implementing, so it has to define these methods

refer A resource adapter needs to implement ManagedConnectionFactory here.

As per the question above , according to JCA 1.6 spec we need to provide implementation for

A resource adapter must provide implementations of the following interfaces:

javax.resource.spi.ManagedConnectionFactory
javax.resource.spi.ManagedConnection
javax.resource.spi.ManagedConnectionMetaData

Which wasnt the case with 1.5

So that is why it gives error during Validation

The JCA validator has become more stringent with version 1.6 , thus the error.

Nothing is much clear about this , there are lot of question and posts on internet about the same issue. Best possible explanation i found was the "requirement" of providing a connection factory.

Also in case you need to bypass the error , you will either need to switch to JCA 1.5 or disable the with 1.6

Community
  • 1
  • 1
Mukul Goel
  • 8,387
  • 6
  • 37
  • 77