0

Spring コアと Spring JDBC を使用する Gradle プロジェクトがあり、Gradle を実行すると正常に実行されます。それをファットジャーに変換すると、プロジェクトは実行されません。

メインプログラムが実行される前にSpring構成がロードされていないと思われます。Gradle を使用して、見栄えの良いファット jar を作成します。エラーと太った瓶の写真を追加しました。これがエラーログです。

ここに画像の説明を入力

ここに画像の説明を入力

ここに画像の説明を入力

C:\CGIADM\Utils\advhealthcheck>java -jar build\libs\advhealthcheck.jar
2019-09-13 16:38:55,625 main DEBUG null null initializing configuration XmlConfiguration[location=jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml]
2019-09-13 16:38:55,625 main DEBUG Installed 1 script engine
2019-09-13 16:38:55,828 main DEBUG Oracle Nashorn version: 1.8.0_151, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
2019-09-13 16:38:55,828 main DEBUG PluginManager 'Core' found 117 plugins
2019-09-13 16:38:55,828 main DEBUG PluginManager 'Level' found 0 plugins
2019-09-13 16:38:55,828 main DEBUG Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
2019-09-13 16:38:55,844 main DEBUG PluginManager 'TypeConverter' found 26 plugins
2019-09-13 16:38:55,844 main DEBUG createProperty(name="pattern", value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [thread-id %T] %l - %msg%n")
2019-09-13 16:38:55,844 main DEBUG Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
2019-09-13 16:38:55,844 main DEBUG createProperty(name="basePath", value="./log")
2019-09-13 16:38:55,844 main DEBUG Building Plugin[name=properties, class=org.apache.logging.log4j.core.config.PropertiesPlugin].
2019-09-13 16:38:55,844 main DEBUG configureSubstitutor(={pattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [thread-id %T] %l - %msg%n, basePath=./log}, Configuration(jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml))
2019-09-13 16:38:55,844 main DEBUG PluginManager 'Lookup' found 13 plugins
2019-09-13 16:38:55,844 main DEBUG Building Plugin[name=Route, class=org.apache.logging.log4j.core.appender.routing.Route].
2019-09-13 16:38:55,860 main DEBUG createRoute(ref="null", key="${ctx:healthcheck}", Node=Route)
2019-09-13 16:38:55,860 main DEBUG Building Plugin[name=Route, class=org.apache.logging.log4j.core.appender.routing.Route].
2019-09-13 16:38:55,860 main DEBUG createRoute(ref="null", key="null", Node=Route)
2019-09-13 16:38:55,860 main DEBUG Building Plugin[name=Routes, class=org.apache.logging.log4j.core.appender.routing.Routes].
2019-09-13 16:38:55,860 main DEBUG Routes$Builder(Configuration(jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml), pattern="${ctx:healthcheck}", Script=null, ={Route(type=dynamic - type=Route key='${ctx:healthcheck}'), Route(type=dynamic - type=Route default)})
2019-09-13 16:38:55,860 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.routing.RoutingAppender].
2019-09-13 16:38:55,875 main DEBUG RoutingAppender$Builder(Script=null, Routes({Route(type=dynamic - type=Route key='${ctx:healthcheck}'),Route(type=dynamic - type=Route default)}), RewritePolicy=null, PurgePolicy=null, ignoreExceptions="null", Layout=null, name="Routing", Configuration(jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml), Filter=null, ={})
2019-09-13 16:38:55,875 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2019-09-13 16:38:55,875 main DEBUG PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [thread-id %T] %l - %msg%n", PatternSelector=null, Configuration(jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2019-09-13 16:38:55,875 main DEBUG PluginManager 'Converter' found 44 plugins
2019-09-13 16:38:55,875 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
2019-09-13 16:38:55,891 main DEBUG ConsoleAppender$Builder(target="SYSTEM_OUT", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [thread-id %T] %l - %msg%n), name="console", Configuration(jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml), Filter=null, ={})
2019-09-13 16:38:55,891 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false
2019-09-13 16:38:55,891 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2019-09-13 16:38:55,891 main DEBUG createAppenders(={Routing, console})
2019-09-13 16:38:55,891 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2019-09-13 16:38:55,891 main DEBUG createAppenderRef(ref="Routing", level="null", Filter=null)
2019-09-13 16:38:55,891 main DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2019-09-13 16:38:55,891 main DEBUG createLogger(additivity="null", level="INFO", includeLocation="null", ={Routing}, ={}, Configuration(jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml), Filter=null)
2019-09-13 16:38:55,891 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2019-09-13 16:38:55,891 main DEBUG createLoggers(={root})
2019-09-13 16:38:55,891 main DEBUG Configuration XmlConfiguration[location=jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml] initialized
2019-09-13 16:38:55,891 main DEBUG Starting configuration XmlConfiguration[location=jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml]
2019-09-13 16:38:55,891 main DEBUG Started configuration XmlConfiguration[location=jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml] OK.
2019-09-13 16:38:55,891 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
2019-09-13 16:38:55,891 main DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
2019-09-13 16:38:55,907 main DEBUG Appender DefaultConsole-1 stopped with status true
2019-09-13 16:38:55,907 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@48533e64 OK
2019-09-13 16:38:55,938 main DEBUG Registering MBean org.apache.logging.log4j2:type=5c647e05
2019-09-13 16:38:55,938 main DEBUG Registering MBean org.apache.logging.log4j2:type=5c647e05,component=StatusLogger
2019-09-13 16:38:55,938 main DEBUG Registering MBean org.apache.logging.log4j2:type=5c647e05,component=ContextSelector
2019-09-13 16:38:55,938 main DEBUG Registering MBean org.apache.logging.log4j2:type=5c647e05,component=Loggers,name=
2019-09-13 16:38:55,938 main DEBUG Registering MBean org.apache.logging.log4j2:type=5c647e05,component=Appenders,name=Routing
2019-09-13 16:38:55,938 main DEBUG Registering MBean org.apache.logging.log4j2:type=5c647e05,component=Appenders,name=console
2019-09-13 16:38:55,938 main DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
2019-09-13 16:38:55,938 main DEBUG Reconfiguration complete for context[name=5c647e05] at URI jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml (org.apache.logging.log4j.core.LoggerContext@74235045) with optional ClassLoader: null
2019-09-13 16:38:55,938 main DEBUG Shutdown hook enabled. Registering a new one.
2019-09-13 16:38:55,953 main DEBUG LoggerContext[name=5c647e05, org.apache.logging.log4j.core.LoggerContext@74235045] started OK.
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.IllegalStateException: Cannot load configuration class: adv.healthcheck.conn.SpringJdbcConfig
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:404)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:249)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:283)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:127)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
        at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
        at adv.tasks.AdvHealthCheckTaskProcessor.addTaskToList(AdvHealthCheckTaskProcessor.java:71)
        at adv.tasks.AdvHealthCheckTaskProcessor.runMainHealthCheckProcessor(AdvHealthCheckTaskProcessor.java:36)
        at adv.tasks.AdvHealthCheckTaskProcessor.main(AdvHealthCheckTaskProcessor.java:31)
Caused by: java.lang.IllegalStateException: Unable to load cache item
        at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79)
        at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
        at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
        at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
        at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
        at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:337)
        at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:138)
        at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:394)
        ... 9 more
Caused by: java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:467)
        at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
        at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:492)
        at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
        at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
        at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
        ... 17 more
Caused by: java.util.NoSuchElementException: get() on Left
        at io.vavr.control.Either$Left.get(Either.java:935)
        at adv.healthcheck.conn.SpringJdbcConfig.<clinit>(SpringJdbcConfig.java:20)
        ... 27 more
2019-09-13 16:38:56,203 pool-1-thread-1 DEBUG Stopping LoggerContext[name=5c647e05, org.apache.logging.log4j.core.LoggerContext@74235045]
2019-09-13 16:38:56,203 pool-1-thread-1 DEBUG Stopping LoggerContext[name=5c647e05, org.apache.logging.log4j.core.LoggerContext@74235045]...
2019-09-13 16:38:56,219 pool-1-thread-1 DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false
2019-09-13 16:38:56,219 pool-1-thread-1 DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false, all resources released: true
2019-09-13 16:38:56,219 pool-1-thread-1 DEBUG Appender console stopped with status true
2019-09-13 16:38:56,219 pool-1-thread-1 DEBUG Stopped XmlConfiguration[location=jar:file:/C:/CGIADM/Utils/advhealthcheck/build/libs/advhealthcheck.jar!/log4j2.xml] OK
2019-09-13 16:38:56,219 pool-1-thread-1 DEBUG Stopped LoggerContext[name=5c647e05, org.apache.logging.log4j.core.LoggerContext@74235045] with status true





    import static adv.util.AdvHealthCheckFileUtils.loadAppConfigFile;
import java.util.Properties;
import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

@Configuration
public class SpringJdbcConfig {

  private static String DRIVER_CLASS_NAME = "driverClassName";
  private static String JDBC_URL = "jdbcurl";
  private static String SCHEMA_USERNAME = "userName";
  private static String SCHEMA_PASSWORD = "password";
  static Properties props;
  static {
    props = loadAppConfigFile().get();
  }
  @Bean
  public DataSource dataSource() {
    return myJdbcDataSource();
  }

  // @Bean
  public DataSource myJdbcDataSource() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(props.getProperty(DRIVER_CLASS_NAME));
    dataSource.setUrl(props.getProperty(JDBC_URL));
    dataSource.setUsername(props.getProperty(SCHEMA_USERNAME));
    dataSource.setPassword(props.getProperty(SCHEMA_PASSWORD));

    return dataSource;
  }
}
4

0 に答える 0