質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Q&A

解決済

2回答

7285閲覧

Eclipse上では実行できるのに、Jarファイルにすると実行できない。

Gchansanjou

総合スコア9

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

0グッド

1クリップ

投稿2018/08/11 03:25

背景

WebアプリケーションをJavaで実装しています。
使用フレームワークはDropwizardです。
ある程度アプリケーションが出来上がったため、Mavenを利用してJarファイルにまとめ、下記のコマンドを実行してみました。

実行コマンド

java -jar testApplication.jar server config.yml

設定ファイル

config.yml

1logging: 2 level: INFO 3 loggers: 4 io.example.application: DEBUG 5 6database: 7 driverClass: org.h2.Driver 8 user: sa 9 password: sa 10 url: jdbc:h2:./target/matome;

エラーが返ってきました。(エラーメッセージ)

INFO [2018-08-11 02:24:05,502] org.eclipse.jetty.util.log: Logging initialized @2543ms to org.eclipse.jetty.util.log.Slf4jLog INFO [2018-08-11 02:24:05,721] io.dropwizard.server.DefaultServerFactory: Registering jersey handler with root path prefix: / INFO [2018-08-11 02:24:05,723] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: / INFO [2018-08-11 02:24:05,724] io.dropwizard.assets.AssetsBundle: Registering AssetBundle with name: assets for path /assets/* INFO [2018-08-11 02:24:06,112] io.dropwizard.server.ServerFactory: Starting testApplicatoin INFO [2018-08-11 02:24:06,301] org.eclipse.jetty.setuid.SetUIDListener: Opened application@885e7ff{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} INFO [2018-08-11 02:24:06,301] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@8bd86c8{HTTP/1.1,[http/1.1]}{0.0.0.0:8081} INFO [2018-08-11 02:24:06,304] org.eclipse.jetty.server.Server: jetty-9.4.z-SNAPSHOT, build timestamp: 2017-11-22T06:27:37+09:00, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8 INFO [2018-08-11 02:24:07,032] org.eclipse.jetty.server.AbstractConnector: Started application@885e7ff{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} INFO [2018-08-11 02:24:07,034] org.eclipse.jetty.server.AbstractConnector: Started admin@8bd86c8{HTTP/1.1,[http/1.1]}{0.0.0.0:8081} java.lang.ExceptionInInitializerError at org.skife.jdbi.v2.sqlobject.SqlObject.buildSqlObject(SqlObject.java:71) at org.skife.jdbi.v2.sqlobject.SqlObjectBuilder.onDemand(SqlObjectBuilder.java:64) at org.skife.jdbi.v2.DBI.onDemand(DBI.java:415) at io.example.applition.testApplicatoin$3.lambda$configure$0(testApplicatoin.java:84) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at io.example.applition.testApplicatoin.registerModules(testApplicatoin.java:115) at io.example.applition.testApplicatoin.access$000(testApplicatoin.java:31) at io.example.applition.testApplicatoin$3.configure(testApplicatoin.java:81) at org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:187) at org.glassfish.jersey.model.internal.CommonConfig.configureBinders(CommonConfig.java:676) at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:641) at org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:829) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:453) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369) at javax.servlet.GenericServlet.init(GenericServlet.java:244) at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665) at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at com.codahale.metrics.jetty9.InstrumentedHandler.doStart(InstrumentedHandler.java:103) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:273) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:252) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.server.Server.start(Server.java:418) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:385) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53) at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:44) at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:85) at io.dropwizard.cli.Cli.run(Cli.java:75) at io.dropwizard.Application.run(Application.java:93) at io.example.applition.testApplicatoin.main(testApplicatoin.java:40) Caused by: java.lang.IllegalArgumentException at org.objectweb.asm.ClassVisitor.<init>(ClassVisitor.java:79) at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:49) at net.sf.cglib.core.DefaultGeneratorStrategy.getClassVisitor(DefaultGeneratorStrategy.java:30) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24) at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:174) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:153) at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73) ... 74 more

試したこと

  • エラー箇所のデバッグ

  ⇨ 階層が深くよくわからない。(エラーメッセージを参考)

  • 環境差異

  ⇨ Eclipseの「DropwizardTool」では実行可能。
⇨ Eclipseの「Javaアプリケーション」では実行可能。
⇨ Windows(Windows10)のCMD上でコマンドを実行すると、上記エラーが発生。
⇨ Linux(Ubuntu 18.04 LTS)のターミナル上でコマンドを実行すると、上記エラーが発生。

お聞きしたいこと

  • Eclipseで実行する環境とJarファイルにしてコマンドで実行する場合の環境でどのような違いが考えられますか?。
  • また、どうすれば実行できるようになるでしょうか?(ざっくりすぎだろ!)
  • みなさんは今回のようなケースの経験ありますか?

補足

「もっと詳しくかけよ!」や「もっと考えなさい。」、「ちゃんとデバッグしろ」等などなんでも良いです。皆様のご回答をお待ちしています。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rubytomato

2018/08/11 05:07

pom.xmlの内容が気になるのですが差し支えなければ質問に追記できますでしょうか?
退会済みユーザー

退会済みユーザー

2018/08/11 10:42

windows 向けネイティブライブラリがはいってそうだなぁ 何入れてんのか知らんが
Gchansanjou

2018/08/12 01:29

> rubytomatoさん ご質問ありがとうございます。 プロジェクト名や、親POMの情報は伏せさせていただきます。 必要であれば対応します! ``` pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>****************</groupId> <artifactId>*********-parent</artifactId> <version>******</version> </parent> <groupId>*************</groupId> <artifactId>*******</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <mainClass>********************</mainClass> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>****************</groupId> <artifactId>**************</artifactId> <version>*******</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-core</artifactId> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> </dependency> <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> </dependency> <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm-debug-all</artifactId> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-assets</artifactId> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-client</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-jdbi</artifactId> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <exclusions> <exclusion> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> </exclusion> <exclusion> <groupId>org.ow2.asm</groupId> <artifactId>asm</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.antlr</groupId> <artifactId>antlr-runtime</artifactId> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-migrations</artifactId> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-views-mustache</artifactId> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-metrics-ganglia</artifactId> </dependency> <dependency> <groupId>com.rometools</groupId> <artifactId>rome</artifactId> <version>1.11.0</version> </dependency> <dependency> <groupId>com.rometools</groupId> <artifactId>rome-fetcher</artifactId> <version>1.11.0</version> </dependency> <dependency> <groupId>org.modelmapper</groupId> <artifactId>modelmapper</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>com.esotericsoftware</groupId> <artifactId>kryo</artifactId> <exclusions> <exclusion> <groupId>org.ow2.asm</groupId> <artifactId>asm</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.dropwizard</groupId> <artifactId>dropwizard-testing</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> <resource> <directory>${project.basedir}</directory> <includes> <include>NOTICE</include> <include>license_third-party/**</include> </includes> <targetPath>${project.build.directory}/classes/META-INF</targetPath> </resource> </resources> <plugins> <plugin> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-versions</id> <goals> <goal>enforce</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-shade-plugin</artifactId> <configuration> <artifactSet> <excludes> <exclude>org.glassfish.jersey.bundles.repackaged:jersey-guava</exclude> </excludes> </artifactSet> <filters> <filter> <artifact>cglib:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.core:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.dataformat:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.dataformat:jackson-dataformat-yaml</artifact> <excludes> <exclude>com/fasterxml/jackson/dataformat/yaml/snakeyaml/**</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.datatype:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.jaxrs:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.module:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>com.fasterxml.jackson.module:jackson-module-afterburner</artifact> <excludes> <exclude>com/fasterxml/jackson/module/afterburner/asm/**</exclude> </excludes> </filter> <filter> <artifact>commons-codec:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> <exclude>META-INF/NOTICE.txt</exclude> </excludes> </filter> <filter> <artifact>io.dropwizard:*</
退会済みユーザー

退会済みユーザー

2018/08/12 01:32

あなたこれでよめるとおもってるの?
退会済みユーザー

退会済みユーザー

2018/08/12 01:41

ちなみに必要なのは <dependencies> と <dependencyManagement> 共通部(parent) の同項目も
退会済みユーザー

退会済みユーザー

2018/08/12 01:42

あと <dependencies> 以下にプロジェクト内共通項目があるなら、そっちの pom.xml から同項目も
Gchansanjou

2018/08/12 02:08

申し訳ないです。teratailは本文10000文字までしか投稿できないみたいで、、
rubytomato

2018/08/12 10:38

pom.xmlの記載ありがとうございます。ただbuild以降の途中で途切れていてjarを生成するpluginの設定が確認できませんでした。あと試して頂きたい点があり、H2をインメモリで使用してみてはどうでしょうか。設定ファイルのJDBC URLを変更することでインメモリにできると思います。
Gchansanjou

2018/08/13 05:20

rubytomatoさん。回答ありがとうございます。「ただbuild以降の途中で途切れていてjarを生成するpluginの設定が確認できませんでした。」途切れた部分は以下に記載します。「H2をインメモリで使用してみてはどうでしょうか。設定ファイルのJDBC URLを変更することでインメモリにできると思います。」確認してみましたが、本文と同じ結果になりました....。
Gchansanjou

2018/08/13 05:21

artifact> <excludes> <exclude>versioneye.properties</exclude> </excludes> </filter> <filter> <artifact>javax.annotation:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> <exclude>**/package.html</exclude> </excludes> </filter> <filter> <artifact>javax.servlet:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> <exclude>**/package.html</exclude> </excludes> </filter> <filter> <artifact>joda-time:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> <exclude>META-INF/NOTICE.txt</exclude> </excludes> </filter> <filter> <artifact>org.acplt.remotetea:remotetea-oncrpc</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> <exclude>META-INF/changelog.html</exclude> <exclude>META-INF/docstyle.css</exclude> <exclude>META-INF/readme.html</exclude> </excludes> </filter> <filter> <artifact>org.apache.commons:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> <exclude>META-INF/NOTICE.txt</exclude> </excludes> </filter> <filter> <artifact>org.apache.httpcomponents:*</artifact> <excludes> <exclude>META-INF/DEPENDENCIES</exclude> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>org.apache.tomcat:*</artifact> <excludes> <exclude>LICENSE</exclude> <exclude>NOTICE</exclude> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> </excludes> </filter> <filter> <artifact>org.eclipse.jetty:*</artifact> <excludes> <exclude>about.html</exclude> <exclude>jetty-dir.css</exclude> <exclude>org/eclipse/jetty/favicon.ico</exclude> </excludes> </filter> <filter> <artifact>org.glassfish:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> </excludes> </filter> <filter> <artifact>org.glassfish.jersey.core:jersey-server</artifact> <excludes> <exclude>jersey/repackaged/org/objectweb/asm/**</exclude> </excludes> </filter> <filter> <artifact>org.jboss.logging:*</artifact> <excludes> <exclude>META-INF/LICENSE.txt</exclude> </excludes> </filter> <filter> <artifact>org.jdbi:jdbi</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/NOTICE</exclude> <exclude>org/skife/jdbi/asm/**</exclude> <exclude>org/skife/jdbi/cglib/**</exclude> <exclude>org/skife/jdbi/com/fasterxml/classmate/**</exclude> <exclude>org/skife/jdbi/org/antlr/runtime/**</exclude> </excludes> </filter> <filter> <artifact>org.liquibase:liquibase-core</artifact> <excludes> <exclude>assembly/**</exclude> <exclude>dist/**</exclude> <exclude>buildinfo.properties</exclude> <exclude>liquibasetasks.properties</exclude> <exclude>migratortasks.properties</exclude> <exclude>overview.html</exclude> </excludes> </filter> </filters> <relocations> <relocation> <pattern>com.fasterxml.jackson.dataformat.yaml.snakeyaml</pattern> <shadedPattern>org.yaml.snakeyaml</shadedPattern> </relocation> <relocation> <pattern>com.fasterxml.jackson.module.afterburner.asm</pattern> <shadedPattern>org.objectweb.asm</shadedPattern> </relocation> <relocation> <pattern>jersey.repackaged.com.google.common</pattern> <shadedPattern>com.google.common</shadedPattern> </relocation> <relocation> <pattern>jersey.repackaged.org.objectweb.asm</pattern> <shadedPattern>org.objectweb.asm</shadedPattern> </relocation> <relocation> <pattern>org.skife.jdbi.asm</pattern> <shadedPattern>org.objectweb.asm</shadedPattern> </relocation> <relocation> <pattern>org.skife.jdbi.cglib</pattern> <shadedPattern>net.sf.cglib</shadedPattern> </relocation> <relocation> <pattern>org.skife.jdbi.com.fasterxml.classmate</pattern> <shadedPattern>com.fasterxml.classmate</shadedPattern> </relocation> <relocation> <pattern>org.skife.jdbi.org.antlr.runtime</pattern> <shadedPattern>org.antlr.runtime</shadedPattern> </relocation> </relocations> </configuration> <executions> <execution> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> <version>${maven-project-info-reports-plugin.version}</version> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <version>${maven-javadoc-plugin.version}</version> </plugin> <plugin> <artifactId>maven-surefire-report-plugin</artifactId> <version>${maven-surefire-report-plugin.version}</version> </plugin> <plugin> <artifactId>maven-jxr-plugin</artifactId> <version>${maven-jxr-plugin.version}</version> </plugin> </plugins> </reporting> </project>
guest

回答2

0

ベストアンサー

下記リンクに同じエラーについての質問が出ていて、cgilibをダウングレードすることで解決していました。

mavenで作成したjarとeclipse実行環境のcgilibのバージョンの違いを調べてみてはどうでしょうか。

jarファイル内のcgilibのjarファイル名にバージョンン番号がついていれば、以下のコマンドで確認できます。

jar tf testApplication.jar

eclipseについては、プロジェクトペインの参照ライブラリでアプリケーションが参照しているjarファイルが確認できると思います。

【補足】

ログに出力されるスタックトレースは長くても、内容を見て意味があるのは大体以下の部分くらいです。

java.lang.ExceptionInInitializerError at org.skife.jdbi.v2.sqlobject.SqlObject.buildSqlObject(SqlObject.java:71) at org.skife.jdbi.v2.sqlobject.SqlObjectBuilder.onDemand(SqlObjectBuilder.java:64) at org.skife.jdbi.v2.DBI.onDemand(DBI.java:415) at io.example.applition.testApplicatoin$3.lambda$configure$0(testApplicatoin.java:84) ≪省略≫ Caused by: java.lang.IllegalArgumentException at org.objectweb.asm.ClassVisitor.<init>(ClassVisitor.java:79) at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:49) at net.sf.cglib.core.DefaultGeneratorStrategy.getClassVisitor(DefaultGeneratorStrategy.java:30) ≪省略≫ at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73) ... 74 more
  • testApplicatoin.javaの84行目でデータベース関連の処理呼び出し
  • ライブラリ内のSqlObject.buildSqlObject()の呼び出しでExceptionInInitializerError発生
  • 原因:上記メソッド内でEnhancerクラスを使用している個所があり、Enhancerクラス内のstatic initializer処理の呼び出しの下層で、ClassVisitorクラスの初期化を行う際に、IllegalArgumentException発生

投稿2018/08/27 22:15

編集2018/08/27 23:20
tkmtmkt

総合スコア1800

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Gchansanjou

2018/09/02 09:21

tkmtmktさん。ご回答ありがとうございました。 > mavenで作成したjarとeclipse実行環境のcgilibのバージョンの違いを調べてみてはどうでしょうか。 記載されたURL先の回答の通り、pom.xmlのcglibのバージョンを3.2.6から3.1に変更したところjarでも動作しました。 ``` <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>3.1</version> </dependency> ``` また【補足】の内容も丁寧に分かりやすく、とても参考になりました。 本当にありがとうございました。
guest

0

ExceptionInInitializerErrorstatic初期化子内で例外が起こった際に発生します。static初期化子内のソースコードに目を通してみてはいかかでしょうか。

投稿2018/08/13 13:57

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Gchansanjou

2018/08/14 02:35

回答ありがとうございます。 `static`初期化部分はEnhancer(ライブラリ)内を`new`した時に実行されて、`ExceptionInInitializerError`例外が発生しているみたいです。 `new`した段階で例外が発生するということは、ライブラリの使用方法が間違ってるということでしょうか?
退会済みユーザー

退会済みユーザー

2018/08/14 16:06

static初期化子はクラスがロードされた時に呼ばれるので何かのインスタンス化のタイミングでExceptionInInitializerErrorが出るのは不自然な感じがします…
退会済みユーザー

退会済みユーザー

2018/08/14 16:10

「`static`初期化部分はEnhancer(ライブラリ)内を`new`した時に実行されて、`ExceptionInInitializerError`例外が発生しているみたいです。」 これは「あなたが書いたstatic初期化子内でnew」ということで合っていますか?それとも「newされたクラス内にstatic初期化子がある」という事でしょうか?(後者だと不自然な例外です)
退会済みユーザー

退会済みユーザー

2018/08/14 19:40

new のタイミングで初めて定数アクセスなどクラスに初めてアクセスすれば出なかったけ
Gchansanjou

2018/08/17 02:45

osaru2002729さん 後者です。ちなみにnewするクラス、されるクラスもライブラリです。
退会済みユーザー

退会済みユーザー

2018/08/17 08:47

すみません、確かにasahina1979さんのおっしゃるタイミングでも出ることはありました。newするクラスもされるクラスもライブラリなら自分で書いたソースコード自体には問題はないってことですかね…。だとしたらMavenの何かが悪いような気がしますがMavenを触ったことがないので僕は力になれなさそうです…。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問