« Return to Thread: Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.platform.database.DatabasePlatform incompatible with org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform

Re: Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.platform.database.DatabasePlatform incompatible with org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform

by dmitryerkin :: Rate this Message:

Reply to Author | View in Thread

Hi, James Sutherland
Thanks for your answer!

I deployed the eclipselink.jar as a shared library so my ear refers to it.
I need to use a sessions.xml because it can refer to the META-INF/oebs.xml project xml file which includes a mapping.
I do not know another way to refer to the project xml file from the persistence.xml file exactly.

I suppose that error is happening here:

    protected void processLoginConfig(LoginConfig loginConfig, DatasourceLogin login) {
        // Platform class
        String platformClassName = loginConfig.getPlatformClass();
        if (platformClassName != null) {
            try {
                Class platformClass = m_classLoader.loadClass(platformClassName);
                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                    login.usePlatform((DatasourcePlatform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass)));
                }else{
                    login.usePlatform((DatasourcePlatform)PrivilegedAccessHelper.newInstanceFromClass(platformClass));
                }
            } catch (Exception exception) {
                throw SessionLoaderException.failedToLoadTag("platform-class", platformClassName, exception);
            }
        }


Do You mean I can implement the SessionCustomizer interface to set the platform which I need to use?

Regards
Dmitry



Odd, seems to be a class-loader issue.  Where did you put the eclipselink.jar on your classpath (system, applib, ear)?  Do you still get the error if you don't use a sessions.xml, just set the platform in the persistence.xml property?

As a workaround you could probably set the platform through a SessionCustomizer.

dmitryerkin wrote:
hi
I am trying to start an application which has an ejb3 module.
This module is configured to use the eclipselink persistence provider.
I receive next error while the application is starting:

Exception Description: Predeployment of PersistenceUnit [oebsEJB] failed.
Internal Exception: Exception [EclipseLink-9003] (Eclipse Persistence Services - 1.0 (Build 1.0 - 20080707)): org.eclipse.persistence.exceptions.SessionLoaderException
Exception Description: Unable to process XML tag [platform-class] with value [org.eclipse.persistence.platform.database.oracle.Oracle10Platform].
Internal Exception: java.lang.ClassCastException:
org.eclipse.persistence.platform.database.oracle.Oracle10Platform incompatible with org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform


here are my xml files.

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 ../../../eclipselink/src/xsd/persistence_1_0.xsd ">
        <persistence-unit name="oebsEJB">
                <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
                <properties>
                        <property name="eclipselink.sessions-xml" value="sessions.xml"/>
                        <property name="eclipselink.session-name" value="oebs"/>
                </properties>
        </persistence-unit>
</persistence>

sessions.xml:
<?xml version="1.0" encoding="UTF-8"?>
<sessions version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <session xsi:type="server-session">
      <name>oebs</name>
      <server-platform xsi:type="websphere-61-platform"/>
      <event-listener-classes/>
      <logging xsi:type="eclipselink-log"/>
      <primary-project xsi:type="xml">META-INF/oebs.xml</primary-project>
      <login xsi:type="database-login">
         <platform-class>org.eclipse.persistence.platform.database.oracle.Oracle10Platform</platform-class>
         <password></password>
         <external-connection-pooling>true</external-connection-pooling>
         <external-transaction-controller>true</external-transaction-controller>
         <sequencing>
            <default-sequence xsi:type="table-sequence">
               <name>Default</name>
            </default-sequence>
         </sequencing>
         <datasource>jdbc/oebs</datasource>
         <struct-converters/>
      </login>
      <connection-pools>
         <read-connection-pool>
            <name>ReadConnectionPool</name>
            <exclusive>false</exclusive>
         </read-connection-pool>
         <write-connection-pool>
            <name>default</name>
         </write-connection-pool>
      </connection-pools>
      <connection-policy/>
   </session>
</sessions>

The platform-class is located in the sessions.xml file.

The application server which I use is Websphere AS 6.1.0.17.

Why can not eclipselink do an explicit type conversion between org.eclipse.persistence.platform.database.DatabasePlatform and org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform although DatabasePlatform is the children of DatasourcePlatform?

Regards
Dmitry

 « Return to Thread: Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.platform.database.DatabasePlatform incompatible with org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform