Steps to reproduce the bug:
- Have a working instance of the Oracle database with some test schema. Schema name is very important and must be other than APP or JBATCH - in my case it was simply BATCH.
- Install GlassFish Server Open Source Edition 4.0 with the default domain1 domain.
- Install Oracle JDBC driver for the target database, i.e. place the driver's JAR file in domain's lib directory.
- Execute the %GLASSFISH_HOME%\glassfish\lib\install\databases\jsr352-oracle.sql script in the target database schema.
- Create jdbc connection pool to Oracle database schema, say jdbc/pool/oracle.
- Create jdbc resource (jdbc/oracle) that wraps the jdbc/pool/oracle
- Set jdbc/oracle resource as the target data source for the batch configuration in server instance
- Restart domain - not sure if it's necessary, but I think it is.
- Deploy the webserverlog application from Java EE 7 tutorial - will try to upload app archive.
- Go to http://localhost:8080/webserverlog/ and click the "Start Batch Job" button - it shall fail with the "java.sql.SQLSyntaxErrorException: ORA-00922: missing or invalid option".
I spent half of the day tracing the cause of this problem and it seems that the reference batch implementation that is part of the GlassFish server always sets the APP schema on the database connection before proceeding with any database operation, as can be seen in the getConnection method. I found this out by turning on the JDBC driver's logging (by adding the JVM system property -Doracle.jdbc.Trace=true) and adding new logger (logger name: oracle, level: FINEST).