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

View: New views
6 Messages — Rating Filter:   Alert me  

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 Threaded | Show Only this Message

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

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

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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 Threaded | Show Only this Message

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


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 Threaded | Show Only this Message

Hi
I followed the tip which I got but it still does not work.
I get the same error in both cases when I deploy the eclipselink.jar with an ear or as a shared library.
I implemented the SessionCustomizer interface but my implementation is not invoked while the ear is starting.

Here is my code:

package java;

import org.eclipse.persistence.config.SessionCustomizer;
import org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform;
import org.eclipse.persistence.sessions.Session;

public class OebsSessionCustomizer implements SessionCustomizer {

        public void customize(Session session) throws Exception {

                session.getLogin().usePlatform(new org.eclipse.persistence.platform.database.oracle.Oracle10Platform());
        }
}


Here is my 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"/>
                        <property name="eclipselink.session.customizer" value="java.OebsSessionCustomizer"/>
                </properties>
        </persistence-unit>
</persistence>


Can you tell me why the customize method is not called?


Regards
Dmitry


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


James Sutherland wrote:
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

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

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Make sure you remove the platform from the sessions.xml.

Your customizer is correct.


dmitryerkin wrote:
Hi
I followed the tip which I got but it still does not work.
I get the same error in both cases when I deploy the eclipselink.jar with an ear or as a shared library.
I implemented the SessionCustomizer interface but my implementation is not invoked while the ear is starting.

Old Sequence behavior on "long id" is broken by Rev 2000 under bug#220394 - improve insert performance

by Sebastien Tardif-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

James,

Old Sequence behavior on "long id" is broken by Rev 2000 under
bug#220394 -improves insert performance.

I have an application that works in many previous version of TopLink.
However, on EclipseLink, it doesn't work anymore.

Most but not all of my domain objects use "long id" for mapped primary
key. Default initialization in Java for long is 0. So our application
99% of all objects setup the mapping to tell that attribute "id"
"default null value" is Long == 0 using TopLink/EclipseLink workbench.

We do communicate to TopLink that id == 0 is equivalent to null but the
new sequence code doesn't care anymore about what we specify. We see the
new code has removing a feature and making the Workbench "default null
value" feature most of the time useless in our case.

You probably already heard of the "Null Pattern". That's why we avoid
using Long instead of "long". With Java 5 it's even worst, if we use
Long and some client code expect "long" Java will do an implicit cast
but at runtime will throw NullPointerException.

It looks weird from the client code that we call assignSequenceNumber
when our sequence field in not explicitly initialized and the method
refuse to assign the sequence.

I really doubt that that checking what is the definition of null in the
descriptor for the field involved can be visible in a profiler.

The guilty method is:

    public Object assignSequenceNumber(Object object, AbstractSession
writeSession) throws DatabaseException {
        DatabaseField sequenceNumberField =
this.descriptor.getSequenceNumberField();
        Object existingValue = getBaseValueForField(sequenceNumberField,
object);
        // If the value is null or zero (int/long) return.
        // PERF: The (internal) support for letting the sequence decide
this was removed,
        // as anything other than primitive should allow null and
default as such.
        if (existingValue != null &&
!Helper.isEquivalentToNull(existingValue)) {
            return null;
        }

   /**
     * Check if the value is null, or 0 (int/long) for primitive ids.
     */
    public static boolean isEquivalentToNull(Object value) {
        return (value == null)
                        || (!isZeroValidPrimaryKey
                                && (((value.getClass() ==
ClassConstants.LONG) && (((Long)value).longValue() == 0L))
                                        || ((value.getClass() ==
ClassConstants.INTEGER) && (((Integer)value).intValue() == 0))));
    }

https://bugs.eclipse.org/bugs/show_bug.cgi?id=233247

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users