[
https://issues.jboss.org/browse/AS7-3110?page=com.atlassian.jira.plugin.s...
]
Hendy Irawan commented on AS7-3110:
-----------------------------------
The fix is almost trivial. In org.jboss.as.jpa.processor.JPAAnnotationParseProcessor :
{code}
private PersistenceUnitMetadata getPersistenceUnit(final DeploymentUnit
deploymentUnit, final AnnotationInstance annotation, EEModuleClassDescription
classDescription)
throws DeploymentUnitProcessingException {
final AnnotationValue puName = annotation.value("unitName");
String searchName = null; // note: a null searchName will match the first PU
definition found
if (puName != null) {
searchName = puName.asString();
}
PersistenceUnitMetadata pu =
PersistenceUnitSearch.resolvePersistenceUnitSupplier(deploymentUnit, searchName);
if (null == pu) {
classDescription.setInvalid(MESSAGES.persistenceUnitNotFound(searchName,
deploymentUnit));
return null;
}
return pu;
}
{code}
Logging (in DEBUG) the classDescription.getClassName() and annotation.toString() would be
tremendously helpful in case of problems.
In my case, it was caused by:
@javax.persistence.PersistenceContext() on void
org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.setEntityManager(javax.persistence.EntityManager)
in org.springframework.data:spring-data-jpa:1.1.0.RC1 .
But it took me a long time to diagnose this problem. Eventually I resorted to grabbing the
jbossas-jpa sources and running JBoss AS in debug mode to find the culprit.
Enhance validation message when multiple persistence units are found
--------------------------------------------------------------------
Key: AS7-3110
URL:
https://issues.jboss.org/browse/AS7-3110
Project: Application Server 7
Issue Type: Enhancement
Components: JPA / Hibernate
Reporter: Markus Dahm
Assignee: Scott Marlow
Priority: Minor
Fix For: 7.2.0.Alpha1
The current message is
Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was
not specified and there are 9 persistence unit definitions in application deployment
"test.ear". Either change the application to have only one persistence unit
definition or specify the unitName for each reference to a persistence unit.
Yet what is always helpful in search of such validation errors is the context.
In that case the offending class name would suffice, you should have this information at
hands since you're scanning the classes, right?
Given that information I'd have found the problem immediately.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira