Moving from ToplinkLink Essentials (SessionCustomizer problem) [message #388482] |
Mon, 01 June 2009 10:54  |
Eclipse User |
|
|
|
Hi,
I moved from Toplink Essentials to EclipseLink with Tomcat 6.0.18 and have
this problem:
I created two web applications both uses EclipseLink. Due to using
non-jta-datasources I created in both applications
JPAEclipseLinkSessionCustomizer class as shown here:
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_ Tutorial
When I start one application everything works fine. As soon as I run the
other application which uses EclipseLink I got exception:
Exception EclipseLink-28014 (Eclipse Persistence Services -
1.1.1.v20090430-r4097):
org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Exception was thrown while processing property
(eclipselink.session.customizer) with value
(hlaseni.JPAEclipseLinkSessionCustomizer).
Internal Exception: java.lang.ClassCastException:
hlaseni.JPAEclipseLinkSessionCustomizer cannot be cast to
org.eclipse.persistence.config.SessionCustomizer
Can anyone help?
Thanks
PERSISTENCE.XML
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="hlaseniPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
<non-jta-data-source>java:comp/env/jdbc/Hlaseni</non-jta-data-source >
<class>hlaseni.entity.Zmeny</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.session.customizer"
value="hlaseni.JPAEclipseLinkSessionCustomizer"/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
JPAEclipseLinkSessionCustomizer class:
package hlaseni;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.eclipse.persistence.config.SessionCustomizer;
import org.eclipse.persistence.sessions.JNDIConnector;
import org.eclipse.persistence.sessions.Session;
public class JPAEclipseLinkSessionCustomizer implements SessionCustomizer
{
public void customize(Session session) throws Exception {
JNDIConnector connector = null;
Context context = null;
try {
context = new InitialContext();
if (null != context) {
connector = (JNDIConnector) session.getLogin().getConnector(); // possible
CCE
connector.setLookupType(JNDIConnector.STRING_LOOKUP);
System.out.println("_JPAEclipseLinkSessionCustomizer: configured " +
connector.getName());
} else {
throw new Exception("_JPAEclipseLinkSessionCustomizer: Context is null");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04363 seconds