Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Warnings due to FileSystemNotFoundException #1555

Closed
Captain-P-Goldfish opened this issue Nov 23, 2020 · 4 comments
Closed

Log Warnings due to FileSystemNotFoundException #1555

Captain-P-Goldfish opened this issue Nov 23, 2020 · 4 comments

Comments

@Captain-P-Goldfish
Copy link

Captain-P-Goldfish commented Nov 23, 2020

In our current project we got a nasty warning.

23 Nov 2020 12:44:56,665 [main] WARN  liquibase.resource (JavaLogger.java:23) - Cannot create filesystem for url jar:file:/opt/consent-core/consent-core-exec.jar!/BOOT-INF/lib/accessors-smart-1.2.jar!/: null
java.nio.file.FileSystemNotFoundException
	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(Unknown Source)
	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(Unknown Source)
	at java.base/java.nio.file.Path.of(Unknown Source)
	at java.base/java.nio.file.Paths.get(Unknown Source)
	at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths(ClassLoaderResourceAccessor.java:63)
	at liquibase.resource.ClassLoaderResourceAccessor.init(ClassLoaderResourceAccessor.java:47)
	at liquibase.resource.ClassLoaderResourceAccessor.openStreams(ClassLoaderResourceAccessor.java:94)
	at liquibase.resource.CompositeResourceAccessor.openStreams(CompositeResourceAccessor.java:33)
	at liquibase.parser.core.xml.LiquibaseEntityResolver.resolveEntity(LiquibaseEntityResolver.java:40)
	at java.xml/com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper.resolveEntity(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:91)
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:15)
	at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:586)
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:365)
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:320)
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23)
	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:337)
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:229)
	at liquibase.Scope.lambda$child$0(Scope.java:160)
	at liquibase.Scope.child(Scope.java:169)
	at liquibase.Scope.child(Scope.java:159)
	at liquibase.Scope.child(Scope.java:138)
	at liquibase.Liquibase.runInScope(Liquibase.java:2277)
	at liquibase.Liquibase.update(Liquibase.java:215)
	at liquibase.Liquibase.update(Liquibase.java:201)
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:322)
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:270)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at de.governikus.autent.consent.core.ConsentCore.main(ConsentCore.java:40)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

It seems to be same as in this ticket:

#1276

I updated to liquibase 4.2.0 and the warning is still there:

Here is my setup:

OS: centos 7
JDK: Oracle JDK 11.0.6

package de.governikus.autent.consent.db.config;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Locale;
import java.util.Properties;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import de.governikus.autent.consent.constants.Profiles;
import liquibase.integration.spring.SpringLiquibase;
import lombok.extern.slf4j.Slf4j;


@Order(2)
@Slf4j
@Configuration
@EnableJpaRepositories(basePackages = {DatabaseConfig.PACKAGE_TO_SCAN})
@EnableTransactionManagement
public class DatabaseConfig
{

  protected static final String PACKAGE_TO_SCAN = "de.governikus.autent.consent.db";

  @Value("${database.url:jdbc:hsqldb:mem:consent-core}")
  private String databaseUrl;

  @Value("${database.user:sa}")
  private String databaseUsername;

  @Value("${database.password:}")
  private String databasePassword;

  @Profile(Profiles.NOT_DEVELOPMENT)
  @Bean(name = "datasource")
  public DataSource datasourceMsSqlServer()
  {
    return getMsSqlDataSource();
  }

  @Profile(Profiles.DEVELOPMENT)
  @Bean("datasource")
  public DataSource datasource()
  {
    return resolveDataSourceFromConfiguration();
  }

  @Profile(Profiles.DEVELOPMENT)
  @Bean(name = "liquibase")
  public SpringLiquibase liquibase(DataSource dataSource)
  {
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setDataSource(dataSource);
    liquibase.setChangeLog("classpath:/de/governikus/autent/consent/db/liquibase/db-setup.xml");
    return liquibase;
  }

  @Bean(name = "dbProperties")
  protected Properties additionalProperties(DataSource dataSource)
  {
    Properties properties = new Properties();
    SupportedDataSources.Vendor vendor = SupportedDataSources.getVendor(dataSource);
    setDialect(vendor, properties);
    return properties;
  }

  private void setDialect(SupportedDataSources.Vendor vendor, Properties properties)
  {
    if (SupportedDataSources.Vendor.HSQL.equals(vendor))
    {
      log.info("Using HSQL database.");
      properties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
      properties.setProperty("hibernate.format_sql", "false");
      properties.setProperty("hibernate.show_sql", "false");
    }
    if (SupportedDataSources.Vendor.SQLSERVER.equals(vendor))
    {
      log.info("Using Microsoft SQL Server database.");
      properties.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServer2012Dialect");
    }
  }

  private DataSource resolveDataSourceFromConfiguration()
  {
    if (StringUtils.contains(databaseUrl, "jdbc:sqlserver"))
    {
      return getMsSqlDataSource();
    }
    else if (StringUtils.contains(databaseUrl, "jdbc:hsqldb"))
    {
      log.warn("CAUTION: using development hsqldb database of type: {}",
               databaseUrl.replaceFirst("jdbc:hsqldb:(.*?):.*", "$1"));
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
      dataSource.setUrl(databaseUrl);
      dataSource.setUsername(databaseUsername);
      dataSource.setPassword(databasePassword);
      return dataSource;
    }
    else
    {
      throw new IllegalStateException("unsupported database used. Only Microsoft SQL Server and HSQL are supported. "
                                      + "Connection url is: " + databaseUrl);
    }
  }

  private DriverManagerDataSource getMsSqlDataSource()
  {
    if (StringUtils.contains(databaseUrl, "jdbc:sqlserver"))
    {
      log.info("connecting to SQL server: {}", databaseUrl);
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      dataSource.setUrl(databaseUrl);
      dataSource.setUsername(databaseUsername);
      dataSource.setPassword(databasePassword);
      return dataSource;
    }
    else
    {
      throw new IllegalStateException("tried to resolve a microsoft sql server database connection with a connection "
                                      + "string that is not a valid sql server url: " + databaseUrl);
    }
  }

  @Bean
  protected EntityManagerFactory entityManagerFactory(DataSource dataSource, Properties dbProperties)
  {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(PACKAGE_TO_SCAN);
    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(dbProperties);

    em.afterPropertiesSet();
    return em.getObject();
  }

  @Bean
  protected PlatformTransactionManager transactionManager(DataSource dataSource, Properties dbProperties)
  {
    return new JpaTransactionManager(entityManagerFactory(dataSource, dbProperties));
  }

  @Bean
  public PersistenceExceptionTranslationPostProcessor exceptionTranslation()
  {
    return new PersistenceExceptionTranslationPostProcessor();
  }

  public static class SupportedDataSources
  {

    public static Vendor getVendor(DataSource dataSource)
    {
      SupportedDataSources dsv = new SupportedDataSources();
      try (Connection connection = dataSource.getConnection())
      {
        return dsv.getVendor(connection);
      }
      catch (SQLException e)
      {
        throw new IllegalStateException("Error fetching connection", e);
      }
    }

    public Vendor getVendor(Connection connection)
    {
      String vendorName;
      vendorName = getVendorName(connection);
      String upper = vendorName.toUpperCase(Locale.ENGLISH).replaceAll("\\s", "");
      if (upper.contains(Vendor.SQLSERVER.toString()))
      {
        return Vendor.SQLSERVER;
      }
      if (upper.contains(Vendor.HSQL.toString()))
      {
        return Vendor.HSQL;
      }
      throw new IllegalStateException("Vendor not supported " + vendorName);
    }

    private String getVendorName(Connection connection)
    {
      try
      {
        return connection.getMetaData().getDatabaseProductName();
      }
      catch (SQLException e)
      {
        throw new IllegalStateException("could not get vendor of jdbc connection", e);
      }
    }

    public enum Vendor
    {
      SQLSERVER, HSQL
    }
  }
}
@Captain-P-Goldfish
Copy link
Author

Additional info:

We are running our setup within a docker container with base image centos:7

@molivasdat
Copy link
Contributor

Hi @Captain-P-Goldfish Thanks for writing up this issue. We will add it to the list of issues that we are processing. Does the liquibase update command work and this is a warning in standard out that you would like suppressed or put into a log file?

@Captain-P-Goldfish
Copy link
Author

the liquibase update works without problem. Our problem is simply that the log file is being filled with thousands of lines of these warnings

@JulienCharon
Copy link

We had the same behavior with liquibase 4.0.0, but it seems to be solved with version 4.2.2.

@FBurguer FBurguer closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants