tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "A. Alonso Domínguez" <>
Subject Tomcat 6.0, JPA and Resource Injection
Date Thu, 13 Sep 2007 09:29:03 GMT
Hi there,

I'm trying to set up a web application which uses Java Persistence with 
Tomcat 6.0. I had googled and searched a lot of mailing lists but I 
didn't found a response for my doubts.

My application uses JSF 1.2 from Sun's RI, some of the managed-beans 
defined at that application have a reference to a EntityManager using 
the PersistenceContext annotation. This application has been tested 
using Glassfish and it works perfectly.
Testing the same application (with all necessary jar files) with Tomcat 
throws an exception: javax.naming.NameNotFoundException: The name 
java:comp is not associated to this context. This is how my config files 
look like:

<Context path="/benedetti-gestion" reloadable="true">

    <Resource name="jdbc/benedetti" auth="Container" 
        maxActive="100" maxIdle="30" maxWait="10000"
        username="benedetti" password="nsh67eTds" 


<?xml version="1.0" encoding="ISO-8859-1"?>

<persistence xmlns=""
    <persistence-unit name="benedetti" transaction-type="RESOURCE_LOCAL">



I'm configuring the injection of the entity manager as following:

@PersistenceContext(unitName = "benedetti",
            name = "java:comp/jpa/benedetti")
    private EntityManager em;

About JNDI names, I tried names

Almost all I found in the web about this issue is about Tomcat 5.5. 
There is said in many places that Tomcat 5.5 should be treated as a JSE 
environment so no dependency injection of "EntityManager" nor 
"EntityManagerFactory" is possible. But, what about Tomcat 6 ?

I did take a look to the DefaultAnnotationProcessor class at 
"org.apache.catalina.util" and seems to me that class performs 
dependency injection based on the kind of annotation found.

My question is: Can I use entity manager injection with Tomcat 6 or do I 
need to perform a bootstrap using the Persistence class like in Tomcat 5.5 ?


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message