[ 
https://issues.apache.org/jira/browse/DERBY-6887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15273700#comment-15273700
 ] 

Developercookie commented on DERBY-6887:
----------------------------------------

Thank you for your detailed answer. I will try to reproduce the problem. But 
for now I give you some insights about what the code does: it is unit test that 
tests some DAO logic. For each test class the embedded database is created. For 
each unit test the database is cleanup with the corresponding method of Flyway 
which deletes all tables and other structures of the database. Then the next 
test is running and so on.

After the whole test class is finished the database is shutdown with the 
following method:
{code}
public void shutdownDatabase() {
        dataSource.setShutdownDatabase(databaseLocation);
        try {
            dataSource.getConnection();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        FileUtils.deleteQuietly(new File(databaseLocation));
    }
{code}

Then the next test class starts by creating the database from new.

Maybe there is problem when deleting the database directory and recreating the 
database. But I will try to write some small test for that.

> NullPointer in 
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl#getTransactionCompile
> -----------------------------------------------------------------------------------------
>
>                 Key: DERBY-6887
>                 URL: https://issues.apache.org/jira/browse/DERBY-6887
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.12.1.1
>         Environment: ------------------ Java-Informationen ------------------
> Java-Version: 1.8.0_77
> Java-Anbieter: Oracle Corporation
> Java Home: /usr/lib/jvm/java-8-oracle/jre
> Java Classpath: 
> /home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derby.jar:/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbynet.jar:/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbytools.jar:/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbyoptionaltools.jar:/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbyclient.jar
> BS-Name: Linux
> BS-Architektur: amd64
> BS-Version: 4.4.0-21-generic
> Java-Benutzername: developercookie
> Java-Benutzer-Home: /home/developercookie
> Java-Benutzerverzeichnis: 
> /home/developercookie/Downloads/db-derby-10.12.1.1-bin/bin
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.8
> java.runtime.version: 1.8.0_77-b03
> --------- Derby-Informationen --------
> [/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derby.jar] 
> 10.12.1.1 - (1704137)
> [/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbytools.jar] 
> 10.12.1.1 - (1704137)
> [/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbynet.jar] 
> 10.12.1.1 - (1704137)
> [/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbyclient.jar] 
> 10.12.1.1 - (1704137)
> [/home/developercookie/Downloads/db-derby-10.12.1.1-bin/lib/derbyoptionaltools.jar]
>  10.12.1.1 - (1704137)
> ------------------------------------------------------
> ----------------- Informationen zum Gebietsschema -----------------
> Aktuelles Gebietsschema:  [Deutsch/Deutschland [de_DE]]
> Folgende Gebietsschemaunterstützung gefunden: [cs]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [de_DE]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [es]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [fr]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [hu]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [it]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [ja_JP]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [ko_KR]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [pl]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [pt_BR]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [ru]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [zh_CN]
>        Version: 10.12.1.1 - (1704137)
> Folgende Gebietsschemaunterstützung gefunden: [zh_TW]
>        Version: 10.12.1.1 - (1704137)
> ------------------------------------------------------
> ------------------------------------------------------
>            Reporter: Developercookie
>
> Hi,
> I'm using Derby in my application. For migrating databases I use the small 
> library Flayway. While running tests I encountered a NullPointerException 
> when Flayway tries to drop tables for clean up. After digging into the 
> Flayway code I found that the root cause is a NullPointerException within 
> Derby in the method 
> {{org.apache.derby.impl.sql.catalog.DataDictionaryImpl#getTransactionCompile}}.
>  This method calls another method {{getLCC()}} that can return a {{null}} 
> value and this causes the {{NullPointerException}}
> NullPointerException stacktrace:
> {code}
> org.flywaydb.core.api.FlywayException: Unable to drop "APP"."LOCATIONS"
>       at 
> org.flywaydb.core.internal.dbsupport.SchemaObject.drop(SchemaObject.java:82)
>       at 
> org.flywaydb.core.internal.dbsupport.derby.DerbySchema.doClean(DerbySchema.java:81)
>       at org.flywaydb.core.internal.dbsupport.Schema.clean(Schema.java:148)
>       at 
> org.flywaydb.core.internal.command.DbClean$4.doInTransaction(DbClean.java:182)
>       at 
> org.flywaydb.core.internal.command.DbClean$4.doInTransaction(DbClean.java:180)
>       at 
> org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
>       at 
> org.flywaydb.core.internal.command.DbClean.cleanSchema(DbClean.java:180)
>       at org.flywaydb.core.internal.command.DbClean.clean(DbClean.java:130)
>       at org.flywaydb.core.Flyway$3.execute(Flyway.java:1017)
>       at org.flywaydb.core.Flyway$3.execute(Flyway.java:1013)
>       at org.flywaydb.core.Flyway.execute(Flyway.java:1361)
>       at org.flywaydb.core.Flyway.clean(Flyway.java:1013)
>       at 
> org.developercookie.account.dao.DBHelper.cleanupDatabase(DBHelper.java:64)
>       at 
> org.developercookie.account.dao.SingleTransactionDAOTest.cleanupDatabase(SingleTransactionDAOTest.java:235)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
>       at 
> org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
>       at 
> org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
> Caused by: java.sql.SQLException: Java exception: ': 
> java.lang.NullPointerException'.
>       at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>       at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>       at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
>       at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
>       at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
> Source)
>       at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown 
> Source)
>       at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown 
> Source)
>       at 
> org.flywaydb.core.internal.dbsupport.JdbcTemplate.execute(JdbcTemplate.java:219)
>       at 
> org.flywaydb.core.internal.dbsupport.derby.DerbyTable.doDrop(DerbyTable.java:43)
>       at 
> org.flywaydb.core.internal.dbsupport.SchemaObject.drop(SchemaObject.java:80)
>       ... 44 more
> Caused by: ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
>       at org.apache.derby.iapi.error.StandardException.newException(Unknown 
> Source)
>       at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown
>  Source)
>       ... 58 more
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getTransactionCompile(Unknown
>  Source)
>       at 
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndex(Unknown
>  Source)
>       at 
> org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSequenceDescriptor(Unknown
>  Source)
>       at 
> org.apache.derby.impl.sql.execute.DropSequenceConstantAction.executeConstantAction(Unknown
>  Source)
>       at 
> org.apache.derby.impl.sql.execute.DropTableConstantAction.dropIdentitySequence(Unknown
>  Source)
>       at 
> org.apache.derby.impl.sql.execute.DropTableConstantAction.executeConstantAction(Unknown
>  Source)
>       at org.apache.derby.impl.sql.execute.MiscResultSet.open(Unknown Source)
>       at 
> org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
>       at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown 
> Source)
>       ... 50 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to