[JBoss JIRA] (CDI-523) CDI spec tries to dispose a container-managed entity manager.
by Martin Andersson (JIRA)
[ https://issues.jboss.org/browse/CDI-523?page=com.atlassian.jira.plugin.sy... ]
Martin Andersson updated CDI-523:
---------------------------------
Description:
Section "3.5.2. Declaring a disposer method" has this example:
{code:java}
public class Resources {
@PersistenceContext
@Produces @UserDatabase
private EntityManager em;
public void close(@Disposes @UserDatabase EntityManager em) {
em.close();
}
}
{code}
The disposer method above call {{EntityManager.close()}} on a container-managed entity manager which result in an {{IllegalStateException}} being thrown *and* the entity manager remains open. This is expected as the JPA spec forbids application code to close a container-managed entity manager. JPA 2.1, section "7.9.1 Container Responsibilities" says:
{quote}
The container must throw the IllegalStateException if the application calls EntityManager.close on a container-managed entity manager.
{quote}
This has been proved [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...] and a theoretical walkthough surrounding entity managers combined with CDI scopes is available [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...].
was:
Section "3.5.2. Declaring a disposer method" has this example:
{code:java}
public class Resources {
@PersistenceContext
@Produces @UserDatabase
private EntityManager em;
public void close(@Disposes @UserDatabase EntityManager em) {
em.close();
}
}
{code}
The disposer method above call {{EntityManager.close()}} on a container-managed entity manager which result in an {{IllegalStateException}} being thrown *and* the entity manager remains open.
This has been proved [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...] and a theoretical walkthough surrounding entity managers combined with CDI scopes is available [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...].
> CDI spec tries to dispose a container-managed entity manager.
> -------------------------------------------------------------
>
> Key: CDI-523
> URL: https://issues.jboss.org/browse/CDI-523
> Project: CDI Specification Issues
> Issue Type: Bug
> Affects Versions: 1.2.Final, 1.1.Final
> Reporter: Martin Andersson
>
> Section "3.5.2. Declaring a disposer method" has this example:
> {code:java}
> public class Resources {
> @PersistenceContext
> @Produces @UserDatabase
> private EntityManager em;
>
> public void close(@Disposes @UserDatabase EntityManager em) {
> em.close();
> }
> }
> {code}
> The disposer method above call {{EntityManager.close()}} on a container-managed entity manager which result in an {{IllegalStateException}} being thrown *and* the entity manager remains open. This is expected as the JPA spec forbids application code to close a container-managed entity manager. JPA 2.1, section "7.9.1 Container Responsibilities" says:
> {quote}
> The container must throw the IllegalStateException if the application calls EntityManager.close on a container-managed entity manager.
> {quote}
> This has been proved [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...] and a theoretical walkthough surrounding entity managers combined with CDI scopes is available [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...].
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
9 years, 7 months
bean archives
by Emily Jiang
I have a question on bean archives.
For the jars under web-inf\lib, are they individual bean archives or they
should be merged together with web-inf\classes files and use the beans.xml
under web-inf\ to form one bean archive?
If they are merged together to form one bean archive, what will happen if
they have their own beans.xml under Meta-inf dir?
Below is the what spec says, but it does not mention the jar under
web-inf\lib. The spec should make this situation clear.
In the CDI1.2 spec:
When determining which archives are bean archives, the container must
consider:
• Library jars, EJB jars or application client jars
• The WEB-INF/classes directory of a war
• Directories in the JVM classpath
The container is not required to support application client jar bean
archives.
A Java EE container is required by the Java EE specification to support
Java EE modules. Other
containers may or may not provide support for war, EJB jar or rar bean
archives.
The beans.xml file must be named:
• META-INF/beans.xml , or,
• in a war, WEB-INF/beans.xml or WEB-INF/classes/META-INF/beans.xml.
--
Thanks
Emily
=================
Emily Jiang
ejiang(a)apache.org
9 years, 7 months