[
https://issues.jboss.org/browse/AS7-946?page=com.atlassian.jira.plugin.sy...
]
Marius Bogoevici commented on AS7-946:
--------------------------------------
Scott, I agree with you, but I feel the need to articulate a bit clearer the reasons for
opening this issue:
a) Given a web application that deployed on JBAS7, if the deployment of the persistence
unit is suppressed through various means - ranging from deploying META-INF/persistence.xml
under a different name, or instructing the server to ignore it, the @PU/@PC annotations
are handled even on classes which are not managed objects in the Java EE sense - this
causes the application to fail deployment. This happens when the deployment unit is a
top-level PU as well (war). Perhaps a reasonable solution would be to avoid doing any JPA
deployment work, but then the deployment may contain @PersistenceContext references on
things like @EJBs, and in that case the deployment must fail or the application must
break.
b) If the @PU/@PC annotations are placed on methods which are not setters, this will break
the deployment as well, even if a PU is found. Again, this may be requirement for managed
instances, but non-managed instances aren't necessarily bound by that rule, so perhaps
we could simply ignore these cases and issue a warning?
I think that these concerns are somewhat complementary to the ones you formulated in your
comment above.
Overall, I see the solution as a compromise between not doing some very complex and
perhaps expensive checks at deployment time, being as lenient as possible, and throwing
errors as early as possible in the deployment cycle.
Persistence annotation processing is overly restrictive
---------------------------------------------------------
Key: AS7-946
URL:
https://issues.jboss.org/browse/AS7-946
Project: Application Server 7
Issue Type: Bug
Components: JPA / Hibernate
Affects Versions: No Release
Reporter: Marius Bogoevici
Assignee: jaikiran pai
If a deployment contains classes bearing the @PersistenceContext annotation, the
annotation processor will fail the deployment if a persistence unit is not found. While
this is correct for classes which are a target for container-driven injection, the
application may contain annotated classes that are not injection targets according to the
Java EE specification. This is not illegal according to the specification.
To wit, a Spring application may use @PersistenceContext for performing Spring-driven
injection of Spring-managed entity manager factories.
In the past, such applications could have used the 'metadata-complete' attribute
in web.xml, but this does not seem to work anymore.
Regardless, of that, the server could adopt a more lenient approach, by failing the
injection only when a managed bean is actually injected with a non-existent PU/PC
reference.
The other variant would be to restrict validation to classes which are actual injection
targets according to the Java EE specification.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira