spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

AOT bean definition for EmbeddedDatabaseFactoryBean is generated in javax.sql package

Open sbrannen opened this issue 3 years ago • 0 comments

This was discovered while executing DirtiesContextTransactionalTestNGSpringContextTests from spring-test in AOT mode.

The config file DirtiesContextTransactionalTestNGSpringContextTests-context.xml contains the following.

<jdbc:embedded-database id="dataSource" />

AOT processing generates the following source code in the javax.sql package.

---- source:   javax/sql/DataSource__TestContext004_BeanDefinitions.java

package javax.sql;

import java.lang.Class;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean;

/**
 * Bean definitions for {@link DataSource}
 */
public class DataSource__TestContext004_BeanDefinitions {
  /**
   * Get the bean definition for 'dataSource'
   */
  public static BeanDefinition getDataSourceBeanDefinition() {
    Class<?> beanType = EmbeddedDatabaseFactoryBean.class;
    RootBeanDefinition beanDefinition = new RootBeanDefinition(beanType);
    beanDefinition.getPropertyValues().addPropertyValue("generateUniqueDatabaseName", "false");
    beanDefinition.getPropertyValues().addPropertyValue("databaseName", "dataSource");
    beanDefinition.getPropertyValues().addPropertyValue("databaseType", "HSQL");
    beanDefinition.setInstanceSupplier(EmbeddedDatabaseFactoryBean::new);
    return beanDefinition;
  }
}

Compilation fails as follows:

package exists in another module: java.sql javax/sql/DataSource__TestContext004_BeanDefinitions.java 1:1
cannot find symbol
  symbol:   class DataSource__TestContext004_BeanDefinitions
  location: package javax.sql org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests__TestContext004_BeanFactoryRegistrations.java 3:17

sbrannen avatar Sep 09 '22 16:09 sbrannen