Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Moving to EclipseLink (SessionCustomizer problem)

692688May 30 2009 — edited Jun 3 2009
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 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.EntityManagerSetupException
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>

CLASS JPAEclipseLinkSessionCustomizer:
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();
}
}
}
This post has been answered by obrienmi8 on Jun 2 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2009
Added on May 30 2009
5 comments
6,320 views