[JAVA] When I ran a jar created using WildFly Swarm, I got an InvocationTargetException.

Occurrence event

I created a REST API using WildFly-Swarm, but when I execute the jar file, an InvocationTargetException occurs and the jar cannot be executed.

environment

Execution environment

java version :1.8.0_131 OS: Windows 10 version 1607

Development environment

Eclipse:4.6.3

Execution command and error log

>java -jar target-swarm.jar
2017-05-06 11:23:15,594 INFO  [org.wildfly.swarm](main) WFSWARM0013: Installed fraction:                  Logging - STABLE          org.wildfly.swarm:logging:2017.4.0
2017-05-06 11:23:15,601 INFO  [org.wildfly.swarm](main) WFSWARM0013: Installed fraction:          Bean Validation - STABLE          org.wildfly.swarm:bean-validation:2017.4.0
2017-05-06 11:23:15,603 INFO  [org.wildfly.swarm](main) WFSWARM0013: Installed fraction:                   JAX-RS - STABLE          org.wildfly.swarm:jaxrs:2017.4.0
2017-05-06 11:23:15,603 INFO  [org.wildfly.swarm](main) WFSWARM0013: Installed fraction:                 Undertow - STABLE          org.wildfly.swarm:undertow:2017.4.0
2017-05-06 11:23:15,604 WARN  [org.wildfly.swarm](main) WFSWARM0013: Installed fraction:                  Swagger - UNSTABLE        org.wildfly.swarm:swagger:2017.4.0
2017-05-06 11:23:18,790 ERROR [stderr](main) java.lang.reflect.InvocationTargetException
2017-05-06 11:23:18,792 ERROR [stderr](main)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2017-05-06 11:23:18,793 ERROR [stderr](main)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2017-05-06 11:23:18,794 ERROR [stderr](main)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2017-05-06 11:23:18,794 ERROR [stderr](main)   at java.lang.reflect.Method.invoke(Unknown Source)
2017-05-06 11:23:18,795 ERROR [stderr](main)   at org.wildfly.swarm.bootstrap.MainInvoker.invoke(MainInvoker.java:39)
2017-05-06 11:23:18,796 ERROR [stderr](main)   at org.wildfly.swarm.bootstrap.Main.run(Main.java:46)
2017-05-06 11:23:18,797 ERROR [stderr](main)   at org.wildfly.swarm.bootstrap.Main.main(Main.java:37)
2017-05-06 11:23:18,797 ERROR [stderr](main) Caused by: java.lang.NoClassDefFoundError: org/wildfly/security/manager/WildFlySecurityManager
2017-05-06 11:23:18,798 ERROR [stderr](main)   at org.jboss.as.server.SelfContainedContainer.start(SelfContainedContainer.java:119)
2017-05-06 11:23:18,798 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.RuntimeServer.start(RuntimeServer.java:202)
2017-05-06 11:23:18,799 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.RuntimeServer$Proxy$_$$_WeldClientProxy.start(Unknown Source)
2017-05-06 11:23:18,799 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.lambda$null$0(ServerBootstrapImpl.java:149)
2017-05-06 11:23:18,800 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.LogSilencer$SilentExecutor.execute(LogSilencer.java:60)
2017-05-06 11:23:18,802 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.lambda$bootstrap$1(ServerBootstrapImpl.java:116)
2017-05-06 11:23:18,803 ERROR [stderr](main)   at org.wildfly.swarm.spi.api.ClassLoading.withTCCL(ClassLoading.java:43)
2017-05-06 11:23:18,804 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.bootstrap(ServerBootstrapImpl.java:109)
2017-05-06 11:23:18,805 ERROR [stderr](main)   at org.wildfly.swarm.Swarm.start(Swarm.java:369)
2017-05-06 11:23:18,806 ERROR [stderr](main)   at org.wildfly.swarm.Swarm.main(Swarm.java:611)
2017-05-06 11:23:18,807 ERROR [stderr](main)   ... 7 more
2017-05-06 11:23:18,808 ERROR [stderr](main) Caused by: java.lang.ClassNotFoundException: org.wildfly.security.manager.WildFlySecurityManager from [Module "org.jboss.as.server:main" from BootModuleLoader@176d53b2 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap:main), ClasspathModuleFinder, ContainerModuleFinder(swarm.container:main), ApplicationModuleFinder(swarm.application:main), org.wildfly.swarm.bootstrap.modules.DynamicModuleFinder@971d0d8]]
2017-05-06 11:23:18,809 ERROR [stderr](main)   at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
2017-05-06 11:23:18,809 ERROR [stderr](main)   at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
2017-05-06 11:23:18,812 ERROR [stderr](main)   at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
2017-05-06 11:23:18,813 ERROR [stderr](main)   at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
2017-05-06 11:23:18,814 ERROR [stderr](main)   ... 17 more
2017-05-06 11:23:18,815 ERROR [stderr](main) Exception in thread "main" java.lang.reflect.InvocationTargetException
2017-05-06 11:23:18,816 ERROR [stderr](main)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2017-05-06 11:23:18,816 ERROR [stderr](main)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2017-05-06 11:23:18,817 ERROR [stderr](main)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2017-05-06 11:23:18,818 ERROR [stderr](main)   at java.lang.reflect.Method.invoke(Unknown Source)
2017-05-06 11:23:18,819 ERROR [stderr](main)   at org.wildfly.swarm.bootstrap.MainInvoker.invoke(MainInvoker.java:39)
2017-05-06 11:23:18,822 ERROR [stderr](main)   at org.wildfly.swarm.bootstrap.Main.run(Main.java:46)
2017-05-06 11:23:18,824 ERROR [stderr](main)   at org.wildfly.swarm.bootstrap.Main.main(Main.java:37)
2017-05-06 11:23:18,825 ERROR [stderr](main) Caused by: java.lang.NoClassDefFoundError: org/wildfly/security/manager/WildFlySecurityManager
2017-05-06 11:23:18,827 ERROR [stderr](main)   at org.jboss.as.server.SelfContainedContainer.start(SelfContainedContainer.java:119)
2017-05-06 11:23:18,827 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.RuntimeServer.start(RuntimeServer.java:202)
2017-05-06 11:23:18,828 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.RuntimeServer$Proxy$_$$_WeldClientProxy.start(Unknown Source)
2017-05-06 11:23:18,829 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.lambda$null$0(ServerBootstrapImpl.java:149)
2017-05-06 11:23:18,830 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.LogSilencer$SilentExecutor.execute(LogSilencer.java:60)
2017-05-06 11:23:18,831 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.lambda$bootstrap$1(ServerBootstrapImpl.java:116)
2017-05-06 11:23:18,835 ERROR [stderr](main)   at org.wildfly.swarm.spi.api.ClassLoading.withTCCL(ClassLoading.java:43)
2017-05-06 11:23:18,836 ERROR [stderr](main)   at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.bootstrap(ServerBootstrapImpl.java:109)
2017-05-06 11:23:18,837 ERROR [stderr](main)   at org.wildfly.swarm.Swarm.start(Swarm.java:369)
2017-05-06 11:23:18,837 ERROR [stderr](main)   at org.wildfly.swarm.Swarm.main(Swarm.java:611)
2017-05-06 11:23:18,838 ERROR [stderr](main)   ... 7 more
2017-05-06 11:23:18,839 ERROR [stderr](main) Caused by: java.lang.ClassNotFoundException: org.wildfly.security.manager.WildFlySecurityManager from [Module "org.jboss.as.server:main" from BootModuleLoader@176d53b2 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap:main), ClasspathModuleFinder, ContainerModuleFinder(swarm.container:main), ApplicationModuleFinder(swarm.application:main), org.wildfly.swarm.bootstrap.modules.DynamicModuleFinder@971d0d8]]
2017-05-06 11:23:18,840 ERROR [stderr](main)   at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
2017-05-06 11:23:18,840 ERROR [stderr](main)   at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
2017-05-06 11:23:18,841 ERROR [stderr](main)   at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
2017-05-06 11:23:18,842 ERROR [stderr](main)   at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
2017-05-06 11:23:18,844 ERROR [stderr](main)   ... 17 more

Research of cause

Survey 1

If you don't have a class, try adding one. So I added the following dependencies to pom.xml.

	<dependency>
	    <groupId>org.wildfly.security</groupId>
	    <artifactId>wildfly-security-manager</artifactId>
	    <version>1.1.2.Final</version>
	</dependency>

The result remains the same.

Survey 2

Try to run it in a Linux environment by following the local execution environment.

The result remains the same.

Survey 3

I doubt the library acquired by maven.

I happened to have a jar that worked on another machine, so when I compared the contents of the jar, m2repo/org/wildfly/security/wildfly-elytron/1.0.2.Final/wildfly-elytron-1.0.2.Final.jar Was different at the binary level.

I don't know why it happened, but I deleted the wildfly-elytron in my local repository and recreated the jar and it worked.

Cause and solution

The cause was that the jar file in the local repository was incorrect. It is solved by deleting the local repository once and running maven again.

Lesson

Maven wasn't too suspicious, but he was the culprit. I don't know why the local repository was corrupted, but if you're not sure what to do, ** suspect Maven's local repository **.

Recommended Posts

When I ran a jar created using WildFly Swarm, I got an InvocationTargetException.
I got an error when I ran rake routes.
I got an error when using nextInt, nextLine and substring.
I got an InvalidUseOfMatchersException when using any with JUnit Mock
Let's create a REST API using WildFly Swarm.
I get an error when adding a dependency
I got an error when trying to install sbt to build a Scala development environment
Unsupported major.minor version 52.0 A memorandum when I got hooked
When I bcrypt with node + docker, I got an error
A mistake made when displaying an image using Active Storage
I got an ActionController :: MissingExactTemplate even though I have a file
I got an IllegalAccessError when trying to use PowerMock with JUnit
I got a Permission Denied error when I put Laravel in Docker