Bug 240244 - [core]: DB Platform auto-detect causes CNFE VendorNameToPlatformMapping requires update to latest class changes
Summary: [core]: DB Platform auto-detect causes CNFE VendorNameToPlatformMapping requi...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 218075
Blocks: 240020
  Show dependency tree
 
Reported: 2008-07-09 17:34 EDT by Michael OBrien CLA
Modified: 2022-06-09 10:23 EDT (History)
2 users (show)

See Also:


Attachments
core.resource.patch (1.24 KB, patch)
2008-07-09 22:18 EDT, Michael OBrien CLA
no flags Details | Diff
propose that Oracle11 from (oracle project) is the default auto-detect (1.56 KB, patch)
2008-07-10 09:02 EDT, Michael OBrien CLA
no flags Details | Diff
The EPL/EDL license header was the 2007 version (all resources) (2.69 KB, patch)
2008-07-10 09:11 EDT, Michael OBrien CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2008-07-09 17:34:54 EDT
Problem:
------------------
I ran across this one when I temporarily removed the target-database and jdbc.platform elements from the persistence unit - I received an expected CNFE on Oracle10Platform - which was recently removed as part of bug# 218075

The same problem will occur for SQLAnywhere users in this case because of the fix in another recent bug.

Reproduction
-------------------
Comment out the following and perform a predeploy:
            <!-- property name="eclipselink.jdbc.platform" value="oracle.toplink.platform.database.oracle.OraclePlatform"/>
            <property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
            <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/-->            


[EL Finest]: 2008.07.09 17:25:40.390--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.oracle.Oracle10Platform, RegularExpression: (?i)oracle.*.
[EL Fine]: 2008.07.09 17:25:40.390--Thread(Thread[main,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.oracle.Oracle10Platform
[EL Finest]: 2008.07.09 17:25:40.405--ServerSession(12014584)--Thread(Thread[main,5,main])--End deploying Persistence Unit statJPA; state Deployed; factoryCount 1
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-7042] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080708)): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Database platform class [org.eclipse.persistence.platform.database.oracle.Oracle10Platform] not found.
Internal Exception: Exception [EclipseLink-3007] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080708)): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [org.eclipse.persistence.platform.database.oracle.Oracle10Platform], of class [class java.lang.String], could not be converted to [class java.lang.Class].  Please ensure that the class [org.eclipse.persistence.platform.database.oracle.Oracle10Platform] is on the CLASSPATH.  You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager
Internal Exception: java.lang.ClassNotFoundException: org.eclipse.persistence.platform.database.oracle.Oracle10Platform
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:267)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100)
	at org.eclipse.persistence.example.navigation.Introspector.initialize(Introspector.java:111)
	at org.eclipse.persistence.example.navigation.Introspector.main(Introspector.java:162)


Fix:
-------------------
In core/resource/org/eclipse/persistence/internal/helper/VendorNameToPlatformMapping.properties

From:
SQL\ Anywhere=org.eclipse.persistence.platform.database.SQLAnyWherePlatform
(?i)oracle.*=org.eclipse.persistence.platform.database.oracle.Oracle10Platform

To:
SQL\ Anywhere=org.eclipse.persistence.platform.database.SQLAnywherePlatform
(?i)oracle.*=org.eclipse.persistence.platform.database.oracle.OraclePlatform
Comment 1 Michael OBrien CLA 2008-07-09 22:18:56 EDT
Created attachment 107026 [details]
core.resource.patch

Oracle10Platform is replaced by the generic OraclePlatform
SQLAnyWhere is renamed SQLAnywhere
Todo: Require new JPA tests for platform generation in the absence of a target-server element
Comment 2 Michael OBrien CLA 2008-07-10 08:55:18 EDT
Reviewed with Tom, the CNFE is normal if the run target of the app does not include the org.eclipse.persistence.oracle project in the classpath which is in the eclipselink.jar - as the Oracle9|10|11Platform classes solely exist there now.

Q) Going forward do we want to move to Oracle11Platforom as the default auto-detect platform for oracle?
Comment 3 Michael OBrien CLA 2008-07-10 09:02:19 EDT
Created attachment 107069 [details]
propose that Oracle11 from (oracle project) is the default auto-detect
Comment 4 Michael OBrien CLA 2008-07-10 09:11:59 EDT
Created attachment 107073 [details]
The EPL/EDL license header was the 2007 version (all resources)
Comment 5 Michael OBrien CLA 2008-07-15 14:31:41 EDT
I need to ask Doug about switching to the Oracle11 platform default
Comment 6 Michael OBrien CLA 2008-07-15 16:38:23 EDT
Retask: (the exception is normal if the client does not have foundation/core.oracle or eclipselink.jar on the classpath)
--------------------------------------
Discussed with PM 
1) we need to refactor the auto-detection code to check the MAJOR/MINOR db version.
2) Before instantiating a platform we should traverse the platform tree to verify that a class exists so a CNFE does not occur in any case.

A platform independent method would be preferred - for example the TC4Connection class states the version number...

via platform dependent...
OracleDatabaseMetaData(OracleDatabaseMetaData).getDatabaseProductName() line: 198 [local variables unavailable]	

or...
Thread [main] (Suspended)	
	DBPlatformHelper.matchVendorNameInProperties(String, Properties, SessionLog) line: 107	
	DBPlatformHelper.getDBPlatform(String, SessionLog) line: 62

versionNumber	10201	
conn	T4CConnection  (id=49)	
	url	"jdbc:oracle:thin:@1...:1521:orcl" (id=195)	
	ver	T4C7Oversion  (id=197)	
	versionNumber	10201	
	
	ServerSession(DatabaseSessionImpl).loginAndDetectDatasource() line: 573	
	EntityManagerFactoryProvider.login(ServerSession, Map) line: 209	
	EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 246	
	EntityManagerFactoryImpl.getServerSession() line: 69	
	EntityManagerFactoryImpl.createEntityManagerImpl(Map, boolean) line: 118	
	EntityManagerFactoryImpl.createEntityManagerImpl(boolean) line: 112	
	EntityManagerFactoryImpl.createEntityManager() line: 100	


The call in ServerSession.loginAndDetectDatasource should also get the version numbers as well as the datasource name and pass these to DBPlatformHelper.matchVendorNameInProperties().

getLogin().setPlatformClassName(DBPlatformHelper.getDBPlatform(conn.getMetaData().getDatabaseProductName(), getSessionLog()));
Comment 7 Peter Krogh CLA 2009-11-27 13:54:41 EST
 This bug is being moved to Future where we can properly sort them all together based on community votes and severity. We will then assign them accordingly to future patch sets and releases.
Comment 8 Peter Krogh CLA 2009-11-30 11:38:10 EST
Changing the priority of the bugs that have been recently triaged to future.  Targetting them to P2 will differentiate them from the P3s that have been triaged into future earlier.
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:17:00 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 10 Eclipse Webmaster CLA 2022-06-09 10:23:18 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink