eclipse-ee4j / eclipse-ee4j/eclipselink

Cannot drop table error in SQLServer 2022

Open
#2,385 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
246
Forks
202
Avg merge
1d 22h
Merged PRs (30d)
14

Description

After the upgradation of SQL Server from 2019 to 2022, 2019 version of the database never returned an error when you tried to drop a table that did not exist, whereas the 2022 version of the database does.The persistence service (in liberty) is requesting an Entity Manager Factory from the EclipseLink provider and it is returning an exception because EclipseLink did not handle the change in behavior of a new version of MS SQLServer
Refer the logs :

[3/17/25, 15:03:48:600 IST] 0000003a id=00000000 eclipselink                                                  W CWWJP9991W: Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B07.v202503061039-a590a7a152a71b58abb295c0b55ff15b3c3a9332): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot drop the table 'SIMPLETESTENTITY', because it does not exist or you do not have permission.
Error Code: 3701
Call: DROP TABLE SIMPLETESTENTITY
Query: DataModifyQuery(sql="DROP TABLE SIMPLETESTENTITY")
[3/17/25, 15:03:48:601 IST] 0000003a id=00000000 eclipselink                                                  3 throwable 
                                                                                                               Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B07.v202503061039-a590a7a152a71b58abb295c0b55ff15b3c3a9332): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot drop the table 'SIMPLETESTENTITY', because it does not exist or you do not have permission.
Error Code: 3701
Call: DROP TABLE SIMPLETESTENTITY
Query: DataModifyQuery(sql="DROP TABLE SIMPLETESTENTITY")
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:337)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:919)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:981)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:642)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:569)
	at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2071)
	at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:611)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:282)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:268)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:325)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:296)
	at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:89)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:934)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3385)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1866)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1848)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1798)
	at org.eclipse.persistence.internal.sessions.AbstractSession.priviledgedExecuteNonSelectingCall(AbstractSession.java:5122)
	at org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition.dropFromDatabase(DatabaseObjectDefinition.java:256)
	at org.eclipse.persistence.tools.schemaframework.SchemaManager.dropObject(SchemaManager.java:555)
	at org.eclipse.persistence.tools.schemaframework.TableCreator.dropTables(TableCreator.java:294)
	at org.eclipse.persistence.tools.schemaframework.TableCreator.dropTables(TableCreator.java:255)
	at org.eclipse.persistence.tools.schemaframework.SchemaManager.dropDefaultTables(SchemaManager.java:1073)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.generateDefaultTables(EntityManagerFactoryProvider.java:121)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDLToDatabase(EntityManagerSetupImpl.java:4752)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeMetadataDDLToDatabase(EntityManagerSetupImpl.java:4819)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:4718)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:4583)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:830)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:233)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:211)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:696)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:462)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:388)
	at com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory(JPAPUnitInfo.java:984)
	at com.ibm.ws.jpa.management.JPAPUnitInfo.initialize(JPAPUnitInfo.java:819)
	at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:190)
	at com.ibm.ws.jpa.management.JPAScopeInfo.processPersistenceUnit(JPAScopeInfo.java:90)
	at com.ibm.ws.jpa.management.JPAApplInfo.addPersistenceUnits(JPAApplInfo.java:121)
	at com.ibm.ws.jpa.container.osgi.internal.JPAComponentImpl.processWebModulePersistenceXml(JPAComponentImpl.java:596)
	at com.ibm.ws.jpa.container.osgi.internal.JPAComponentImpl.applicationStarting(JPAComponentImpl.java:379)
	at com.ibm.ws.container.service.state.internal.ApplicationStateManager.fireStarting(ApplicationStateManager.java:53)
	at com.ibm.ws.container.service.state.internal.StateChangeServiceImpl.fireApplicationStarting(StateChangeServiceImpl.java:52)
	at com.ibm.ws.app.manager.module.internal.SimpleDeployedAppInfoBase.preDeployApp(SimpleDeployedAppInfoBase.java:623)
	at com.ibm.ws.app.manager.module.internal.SimpleDeployedAppInfoBase.installApp(SimpleDeployedAppInfoBase.java:584)
	at com.ibm.ws.app.manager.module.internal.DeployedAppInfoBase.deployApp(DeployedAppInfoBase.java:625)
	at com.ibm.ws.app.manager.war.internal.WARApplicationHandlerImpl.install(WARApplicationHandlerImpl.java:67)
	at com.ibm.ws.app.manager.internal.statemachine.StartAction.execute(StartAction.java:199)
	at com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl.enterState(ApplicationStateMachineImpl.java:1369)
	at com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl.run(ApplicationStateMachineImpl.java:912)
	at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:298)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:857)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot drop the table 'SIMPLETESTENTITY', because it does not exist or you do not have permission.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1632)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:602)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:524)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7418)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3272)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:473)
	at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:522)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:909)
	... 52 more

[3/17/25, 15:03:48:617 IST] 0000003a id=00000000 eclipselink.query                                            3 [eclipselink.query] Execute query DataModifyQuery(sql="DROP TABLE SIMPLETESTENTITY")
[3/17/25, 15:03:48:617 IST] 0000003a id=00000000 eclipselink.connection                                       3 [eclipselink.connection] Connection acquired from connection pool [read].
[3/17/25, 15:03:48:617 IST] 0000003a id=00000000 eclipselink.connection                                       3 [eclipselink.connection] reconnecting to external connection pool
[3/17/25, 15:03:48:617 IST] 0000003a id=00000000 eclipselink.sql                                              3 [eclipselink.sql] DROP TABLE SIMPLETESTENTITY
[3/17/25, 15:03:48:939 IST] 0000003a id=00000000 eclipselink.sql                                              3 [eclipselink.sql] SELECT 1
[3/17/25, 15:03:49:647 IST] 0000003a id=00000000 eclipselink.connection                                       3 [eclipselink.connection] Connection released to connection pool [read].
[3/17/25, 15:03:49:650 IST] 0000003a id=00000000 eclipselink                                                  W CWWJP9991W: Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B07.v202503061039-a590a7a152a71b58abb295c0b55ff15b3c3a9332): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot drop the table 'SIMPLETESTENTITY', because it does not exist or you do not have permission.
Error Code: 3701
Call: DROP TABLE SIMPLETESTENTITY
Query: DataModifyQuery(sql="DROP TABLE SIMPLETESTENTITY")
[3/17/25, 15:03:49:651 IST] 0000003a id=00000000 eclipselink                                                  3 throwable 
                                                                                                               Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B07.v202503061039-a590a7a152a71b58abb295c0b55ff15b3c3a9332): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot drop the table 'SIMPLETESTENTITY', because it does not exist or you do not have permission.
Error Code: 3701
Call: DROP TABLE SIMPLETESTENTITY

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stack path through EntityManagerFactoryProvider.generateDefaultTables, SchemaManager.dropDefaultTables, TableCreator.dropTables, and DatabaseObjectDefinition.dropFromDatabase, then reproduce the DROP TABLE behavior against SQL Server 2022. Done means the persistence setup no longer fails when the target table is absent, with coverage for the reported error path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.