5.3.2 Available components

With Application Server, you can use the JPA with EJBs and Web applications. You can also use the JPA when user threads are used from Web applications. Note that you cannot use the JPA in the following environments or libraries:

The following table lists the components that can use the JPA.

Table 5-2 Components that can use the JPA

ComponentsJPA usage
EJBStateless Session Bean (EJB 3.0 and later)#1Y
Stateful Session Bean (EJB 3.0 and later)#1Y
Stateless Session Bean (earlier than EJB 3.0)N
Stateful Session Bean (earlier than EJB 3.0)N
InterceptorY
Message-driven BeanN
Entity BeanN
Web applicationServlet, filter, event listener (Servlet 2.5 and later)Y
JSP, JSP tag handler, JSP event listener, JSP tag library event listener #2 (Servlet 2.5 and later)Y
Servlet, filter, event listener (earlier than Servlet 2.5)N
JSP, JSP tag handler, JSP event listener, JSP tag library event listener (earlier than Servlet 2.5)N
Legend:
Y: Available
N: Not available

#1: With Application Server, you cannot specify the JPA definition using EJB 3.0 ejb-jar.xml. Therefore, you use annotations such as @PersistenceUnit and @PersistenceContext to define the references for the persistence units and persistence contexts.

#2 With Application Server, you cannot use annotations in the JSP tag library event listener. To use the JPA functionality in the JSP tag library event listener, you use <persistence-unit-ref> tag and the <persistence-context-ref> tag of web.xml to define the references for the persistence units and persistence contexts.


Note
If true is specified in the metadata-complete attribute of web.xml in Servlet 2.5 and later, the Web component annotations are not read. Therefore, you cannot use annotations to define the references for the persistence contexts or persistence units. However, you can define the references in web.xml.