We're updating the issue view to help you get more done. 

Incorrect JPA 2 detection

Description

I was running into some classpath issues with my application which led me to look into the code of the DefaultTraversableResolver class in Hibenate Validator 4.3.2. Specifically, I was looking into the "detectJPA()" method, which doesn't seem to be able to differentiate between JPA 2 and 1 due to a missing "return" statement.

Here's the code from lines 98 to 110:

1 2 3 4 5 6 7 8 9 10 11 12 13 // try to invoke the method to make sure that we are dealing with a complete JPA2 implementation // unfortunately there are several incomplete implementations out there (see HV-374) try { Object persistence = run( NewInstance.action( persistenceClass, "persistence provider" ) ); ReflectionHelper.getValue( persistenceUtilGetter, persistence ); } catch ( Exception e ) { log.debugf( "Unable to invoke %s.%s. Inconsistent JPA environment. All properties will per default be traversable.", PERSISTENCE_CLASS_NAME, PERSISTENCE_UTIL_METHOD ); }

Now, shouldn't this log.debug statement be followed by a return to abort the JPA detection process while concluding that a full-featured implementation of JPA2 is not available? But this is not the case, the detection proceeds assuming a 2.0 version. Here are the directly following lines:

1 2 3 4 5 log.debugf( "Found %s on classpath containing '%s'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver", PERSISTENCE_CLASS_NAME, PERSISTENCE_UTIL_METHOD );

Naturally, when the conclusion is reached that JPA 2.0 is available the JPATraversableResolver is used.

Environment

WebSphere 7 (without JPA 2 feature pack)
Solaris 10 10/09 s10s_u8wos_08a SPARC

Status

Assignee

Hardy Ferentschik

Reporter

Tarek Nabil

Labels

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

4.3.2.Final

Priority

Major