Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] SessionCustomizer problem

Hi,
   Just a note that this issue has been solved in the following parallel post.
   The issue was classpath related in that the javax.persistence jar and eclipselink.jar were at different levels in the classpath tree - eclipselink was moved up higher out of the WAR into the server/lib

http://forums.oracle.com/forums/thread.jspa?threadID=907216&tstart=0

    This post follows guidelines set for running EclipseLink on Tomcat in the following EclipseLink wiki.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial
    specifically
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Persistence_JAR_location
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#EclipseLink_JAR_location
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#non-JTA_.28RESOURCE_LOCAL.29_Persistence.xml

    thank you
    /michael


James Sutherland wrote:
Seems to be a class loader issue.  Ensure that EclipseLink is only on your
classpath once.



Pavel Zelenka wrote:
  
Hi,

I use 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 go 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();
        }
    }
}


    

-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
  


Back to the top