jakartaee/platform-tck

ee.jakarta.tck.persistence.core.StoredProcedureQuery.* tests not seeing stored procedures

Opened this issue · 17 comments

Describe the bug
The ee.jakarta.tck.persistence.core.StoredProcedureQuery.* package on the jpa-web branch tests are failing due to missing stored procedures:

Internal Exception: java.sql.SQLSyntaxErrorException: 'GETEMPIDUSINGHIREDATEFROMOUT' is not recognized as a function or procedure.
Error Code: 20000
Call: CALL GetEmpIdUsingHireDateFromOut(?, ?)
        bind => [2 parameters bound]
Query: ResultSetMappingQuery()
        at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:389)
        at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:265)
        at org.eclipse.persistence.internal.jpa.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:319)
        at ee.jakarta.tck.persistence.core.StoredProcedureQuery.Client1.setParameterParameterDateTemporalTypeTest(Client1.java:1473)

12-17-2024 23:06:28:  SVR-ERROR: jakarta.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B03.v202409121024-4a7149f0cd04d7466837d70f68abb743c88acb83): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: 'GETEMPFIRSTNAMEFROMOUT' is not recognized as a function or procedure.
Error Code: 20000
Call: CALL GetEmpFirstNameFromOut(?, ?)
        bind => [2 parameters bound]
Query: ResultSetMappingQuery()
        at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:389)
        at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:265)
        at org.eclipse.persistence.internal.jpa.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:319)
        at ee.jakarta.tck.persistence.core.StoredProcedureQuery.Client1.setParameterParameterObjectTest(Client1.java:1072)

These exist in the glassfish-runner/persistence-platform-tck/sql/derby/derby.ddl.persistence.sprocs.sql script, and I have updated the pom.xml to execute these, but I'm still seeing this error.

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/jakartaee/platform-tck.git
  2. cd platform-tck
  3. git checkout jpa-web
  4. mvn install
  5. cd platform-tck/glassfish-runner/persistence-platform-tck
  6. mvn test-compile pre-integration-test failsafe:integration-test@jta-tests-javatest | tee run.log
  7. See error2

@alwin-joseph did you setup the jpa standalone tests? I took the sql initialization plugin config from there. Can you take a look if you can see why the stored procedures are not seen please.

@alwin-joseph did you setup the jpa standalone tests? I took the sql initialization plugin config from there. Can you take a look if you can see why the stored procedures are not seen please.

Do you see the execution of derby.ddl.persistence.sprocs.sql passing successfully (18 SQL statements) ?

No I don't:

[INFO] --- antrun:3.1.0:run (initdb) @ glassfish.jpa-platform-tck ---
[INFO] Executing tasks
[INFO]       [sql] Executing resource: /Users/starksm/Dev/Jakarta/platform-tck/glassfish-runner/persistence-platform-tck/sql/derby/derby.ddl.persistence.sql
[INFO]       [sql] 0 of 0 SQL statements executed successfully
[INFO] Executed tasks

Any idea why by looking at the at task?

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>initdb</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <path id="jdbc.classpath">
                                    <pathelement path="target/glassfish8/javadb/lib/derbyclient.jar"></pathelement>
                                    <path refid="maven.runtime.classpath"></path>
                                </path>
                                <sql autocommit="true" classpathref="jdbc.classpath" delimiter=";" driver="org.apache.derby.jdbc.ClientDriver" onerror="continue" password="cts1" url="jdbc:derby://localhost:1527/derbyDB" userid="cts1">
                                    <transaction src="sql/derby/derby.ddl.persistence.sql"></transaction>
                                    <transaction src="sql/derby/derby.ddl.persistence.sprocs.sql"></transaction>
                                </sql>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I am able to run the sql statements derby.ddl.persistence.sprocs.sql and derby.ddl.sql
using alwin-joseph@151dd72 , maybe there is easier way using glassfish commands, but this seem to work for execution.
Also added commit 46d102f to fix an error with connection pool.
Full diffs : https://github.com/jakartaee/platform-tck/compare/web-jpa...alwin-joseph:jakartaee-tck:test-issue1716?expand=1

I had to kill the running database instance (ps -ef | grep glassfish) after every run of
mvn clean test-compile pre-integration-test failsafe:integration-test@jta-tests-javatest | tee run.log.

It seems the file name for the first transaction statement should be derby.ddl.sql rather than derby.ddl.persistence.sql. After changing that I am seeing:

[INFO] --- antrun:3.1.0:run (initdb) @ glassfish.jpa-platform-tck ---
[INFO] Executing tasks
[INFO]       [sql] Executing resource: /Users/starksm/Dev/Jakarta/platform-tck/glassfish-runner/persistence-platform-tck/sql/derby/derby.ddl.sql
[INFO]       [sql] Executing resource: /Users/starksm/Dev/Jakarta/platform-tck/glassfish-runner/persistence-platform-tck/sql/derby/derby.ddl.persistence.sprocs.sql
[INFO]       [sql] 636 of 636 SQL statements executed successfully
[INFO] Executed tasks

but I still see the errors in the test:

12-18-2024 12:01:38:  SVR-ERROR: jakarta.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B03.v202409121024-4a7149f0cd04d7466837d70f68abb743c88acb83): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: 'GETEMPIDUSINGHIREDATEFROMOUT' is not recognized as a function or procedure.
Error Code: 20000
Call: CALL GetEmpIdUsingHireDateFromOut(?, ?)
        bind => [2 parameters bound]
Query: ResultSetMappingQuery()
        at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:389)
        at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:265)
        at org.eclipse.persistence.internal.jpa.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:319)
        at ee.jakarta.tck.persistence.core.StoredProcedureQuery.Client1.setParameterParameterDateTemporalTypeTest(Client1.java:1473)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at com.sun.ts.lib.harness.EETest.run(EETest.java:602)
        at com.sun.ts.lib.harness.ServiceEETest.run(ServiceEETest.java:138)
        at com.sun.ts.tests.common.vehicle.pmservlet.PMServletVehicle.runTest(PMServletVehicle.java:112)
        at com.sun.ts.tests.common.vehicle.servlet.ServletVehicle.doGet(ServletVehicle.java:96)
        at com.sun.ts.tests.common.vehicle.servlet.ServletVehicle.doPost(ServletVehicle.java:116)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:653)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1316)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:563)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:504)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:71)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:121)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:294)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:187)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:429)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:143)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 5.0.0-B03.v202409121024-4a7149f0cd04d7466837d70f68abb743c88acb83): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: 'GETEMPIDUSINGHIREDATEFROMOUT' is not recognized as a function or procedure.
Error Code: 20000
Call: CALL GetEmpIdUsingHireDateFromOut(?, ?)
        bind => [2 parameters bound]
Query: ResultSetMappingQuery()
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:346)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:702)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:569)
        at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2053)
        at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:322)
  

maybe the tables are getting dropped somewhere.

With the latest changes I get below result , if this is better than what you see, can I raise a PR
Tests run: 36, Failures: 0, Errors: 1, Skipped: 0

changes in web-jpa...alwin-joseph:test-issue1716

Yes, I'm still seeing the original 21 errors, so please do create a PR.

Yes, I'm still seeing the original 21 errors, so please do create a PR.

#1717

  • The stop-database-final is part of post-integration-test phase, so I had to kill the database manually before each run
  • I also did clean for each run : mvn clean test-compile pre-integration-test failsafe:integration-test@jta-tests-javatest | tee run.log

It looks like the fix was merged to branch https://github.com/jakartaee/platform-tck/tree/web-jpa but not main.

@alwin-joseph is the change ready to merge to main as well?

I synced my local repo (main branch) with the change and will try running locally.

I think we need to bring @alwin-joseph's changes from the web-jpa branch (as mentioned in #1717) to the main branch. On the web-jpa branch, I see:

[ERROR] Errors:
[ERROR] Client1PmservletTest.getSingleResultOrNullWithNullTest » Test case throws exception: getSingleResultOrNullWithNullTest failed
[INFO]
[ERROR] Tests run: 36, Failures: 0, Errors: 1, Skipped: 0
[INFO]

I created draft pr #1734 to merge changes from the web-jpa branch to main. There look to be some minor merge conflicts to resolve.

Do we have any other in progress changes on the web-jpa branch that we also want to be merged to the main now?

If not, I suggest we go ahead and merge the current changes. What do you think @alwin-joseph + @starksm64?

I created draft pr #1734 to merge changes from the web-jpa branch to main. There look to be some minor merge conflicts to resolve.

Do we have any other in progress changes on the web-jpa branch that we also want to be merged to the main now?

If not, I suggest we go ahead and merge the current changes. What do you think @alwin-joseph + @starksm64?

+1 for merging to main.

I just merged my outstanding change for the JPA tests, so once those are resolved let's merge #1734.

@scottmarlow

tcks/apis/persistence/persistence-inside-container/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/criteriaapi/CriteriaDelete/Client.java

needs this method added:

  public void setup(String[] args, Properties p) throws Fault {
    TestUtil.logTrace("setup");
    try {
      super.setup(args, p);
      removeTestData();
      createProductData();
    } catch (Exception e) {
      TestUtil.logErr("Exception: ", e);
      throw new Fault("setup failed:", e);
    }
  }

#1734 is merged.

Will add the missing setup method to tcks/apis/persistence/persistence-inside-container/spec-tests/src/main/java/ee/jakarta/tck/persistence/core/criteriaapi/CriteriaDelete/Client.java now.