Pavel,
I was able to run EclipseLink JPA using a non-JTA datasource on Tomcat 6.0.18 using the following configuration.
I will update the tutorial with this 3rd type of database connectivity.
1) transaction-type RESOURCE_LOCAL direct connection using "javax.persistence.jdbc" properties - previously working
2) transaction-type RESOURCE_LOCAL non-JTA datasource connection using "non-jta-data-source" or "javax.persistence.nonJtaDataSource" - verified today
3) transaction-type JTA "jta-data-source" - working only when Tomcat is run as a service
2) non-jta-datasource setup for persistence.xml, web.xml and server.xml
Note: if the resource-ref setup is missing or if the jndi names do not match you will see "name not bound" exceptions
persistence.xml
<persistence-unit name="statJPA" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>java:comp/env/ds/OracleDS</non-jta-data-source>
<class>org.eclipse.persistence.example.unified.business.***</class>
<properties>
<property name="eclipselink.session.customizer" value="org.eclipse.persistence.example.unified.integration.JPAEclipseLinkSessionCustomizer"/>
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
<!-- this one overrides -->
<property name="javax.persistence.nonJtaDataSource" value="java:comp/env/ds/OracleDS"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
JPAEclipseLinkSessionCustomizer.java
- matches what is on
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Session_Customizer
web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>UnifiedTomcatWeb</display-name>
<servlet>
<display-name>FrontController</display-name>
<servlet-name>FrontController</servlet-name>
<servlet-class>org.eclipse.persistence.example.unified.presentation.FrontController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FrontController</servlet-name>
<url-pattern>/FrontController</url-pattern>
</servlet-mapping>
<persistence-context-ref>
<persistence-context-ref-name>persistence/em</persistence-context-ref-name>
<persistence-unit-name>statJPA</persistence-unit-name>
</persistence-context-ref>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>ds/OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
server.xml
<GlobalNamingResources>
....
<Resource
name="ds/OracleDS"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="scott"
password="pw"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@y.y.y.y:1521:orcl"
/>
</GlobalNamingResources>
....
<Context
className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="false" debug="0"
displayName="UnifiedTomcatWeb"
docBase="C:\opt\tomcat6018\webapps\UnifiedTomcatWeb.war"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/UnifiedTomcatWeb"
privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<ResourceLink
global="ds/OracleDS"
name="ds/OracleDS"
type="javax.sql.DataSource"/>
</Context>
</Host>
Logs:
[EL Finest]: 2009-06-01 15:19:23.828--ServerSession(13961193)--Thread(Thread[http-8080-1,5,main])--property=javax.persistence.nonJtaDataSource; value=java:comp/env/ds/OracleDS
[EL Finest]: 2009-06-01 15:19:23.844--ServerSession(13961193)--Thread(Thread[http-8080-1,5,main])--property=eclipselink.session.customizer; value=org.eclipse.persistence.example.unified.integration.JPAEclipseLinkSessionCustomizer
_
JPAEclipseLinkSessionCustomizer: configured java:comp/env/ds/OracleDS
[EL Info]: 2009-06-01 15:19:23.844--ServerSession(13961193)--Thread(Thread[http-8080-1,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.0.qualifier
[EL Config]: 2009-06-01 15:19:23.859--ServerSession(13961193)--Connection(6427893)--Thread(Thread[http-8080-1,5,main])--connecting
(DatabaseLogin(
platform=>OraclePlatform
user name=> ""
connector=>JNDIConnector datasource name=>java:comp/env/ds/OracleDS
))
[EL Config]: 2009-06-01 15:19:24.327--ServerSession(13961193)--Connection(24968504)--Thread(Thread[http-8080-1,5,main])--Connected
: jdbc:oracle:thin:@y.y.y.y:1521:orcl
User: SCOTT
Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Driver: Oracle JDBC driver Version: 11.1.0.0.0-Beta5
EL Info]: 2009-06-01 15:19:24.358--ServerSession(13961193)--Thread(Thread[http-8080-1,5,main])--file:/C:/opt/tomcat6018/webapps/UnifiedTomcatWeb/WEB-INF/classes/-statJPA login successful
- user sends "demo" command to servlet....
[EL Finer]: 2009-06-01 15:19:24.39--ServerSession(13961193)--Thread(Thread[http-8080-1,5,main])--client acquired
[EL Finest]: 2009-06-01 15:19:24.39--UnitOfWork(13645178)--Thread(Thread[http-8080-1,5,main])--PERSIST operation called on: org.eclipse.persistence.example.unified.business.StatLabel@b31b77.
[EL Finer]: 2009-06-01 15:19:24.483--UnitOfWork(13645178)--Thread(Thread[http-8080-1,5,main])--begin unit of work commit
[EL Finer]: 2009-06-01 15:19:24.483--ClientSession(26548428)--Connection(16408563)--Thread(Thread[http-8080-1,5,main])--begin transaction
[EL Finest]: 2009-06-01 15:19:24.499--ClientSession(26548428)--Thread(Thread[http-8080-1,5,main])--reconnecting to external connection pool
[EL Finest]: 2009-06-01 15:19:24.499--UnitOfWork(13645178)--Thread(Thread[http-8080-1,5,main])--Execute query InsertObjectQuery(org.eclipse.persistence.example.unified.business.StatLabel@c22a3b)
[EL Fine]: 2009-06-01 15:19:24.499--ClientSession(26548428)--Connection(26760685)--Thread(Thread[http-8080-1,5,main])--INSERT INTO
STAT_LABEL (ID, DATE_STAMP) VALUES (?, ?)
bind => [7127, null]
thank you
/michael