Skip to main content

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

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 
-- 
View this message in context: http://www.nabble.com/SessionCustomizer-problem-tp23785377p23963279.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top