I am testing wildfly bootable jar. Made a simple project and started it with "java -jar myapp-bootable.jar" just fine. It contains basically just a index.html. Simple enough.
Next step, was do build a docker image around it. And this didn't work.
Here is the dockerfile
FROM maven:3.6.3-adoptopenjdk-15 as build
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app
RUN mvn -f /usr/src/app/pom.xml clean package
FROM adoptopenjdk:latest
COPY --from=build /usr/src/app/target/myapp-bootable.jar /opt/myapp-bootable.jar
WORKDIR /opt
CMD ["java", "-jar","myapp-bootable.jar"]
I use the same jdk on my mac and it does work. I really do not understand why I get this error message:
Exception in thread "main" java.lang.Exception: org.jboss.modules.ModuleLoadException: Error loading module from /tmp/wildfly-bootable-server4167855925626750470/modules/system/layers/base/org/apache/xerces/main/module.xml
at org.wildfly.core.jar.boot.Main.runBootableJar(Main.java:162)
at org.wildfly.core.jar.boot.Main.main(Main.java:141)
Caused by: org.jboss.modules.ModuleLoadException: Error loading module from /tmp/wildfly-bootable-server4167855925626750470/modules/system/layers/base/org/apache/xerces/main/module.xml
at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:337)
at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:293)
at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:254)
at org.jboss.modules.LocalModuleFinder.parseModuleXmlFile(LocalModuleFinder.java:250)
at org.jboss.modules.LocalModuleFinder.lambda$findModule$1(LocalModuleFinder.java:195)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
at org.jboss.modules.LocalModuleFinder.findModule(LocalModuleFinder.java:195)
at org.jboss.modules.ModuleLoader.findModule0(ModuleLoader.java:696)
at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:689)
at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:499)
at org.jboss.modules.DelegatingModuleLoader.preloadModule(DelegatingModuleLoader.java:57)
at org.jboss.modules.Module.addPaths(Module.java:1252)
at org.jboss.modules.Module.link(Module.java:1622)
at org.jboss.modules.Module.relinkIfNecessary(Module.java:1650)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:299)
at org.wildfly.core.jar.boot.Main.runBootableJar(Main.java:160)
... 1 more
Caused by: org.jboss.modules.xml.XmlPullParserException: Failed to resolve artifact 'xerces:xercesImpl:2.12.0.SP03' (position: END_TAG seen ...esources>\n <artifact name="xerces:xercesImpl:2.12.0.SP03"/>... @26:57)
at org.jboss.modules.xml.ModuleXmlParser.parseArtifact(ModuleXmlParser.java:1050)
at org.jboss.modules.xml.ModuleXmlParser.parseResources(ModuleXmlParser.java:937)
at org.jboss.modules.xml.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:697)
at org.jboss.modules.xml.ModuleXmlParser.parseDocument(ModuleXmlParser.java:469)
at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:335)
... 16 more
Everything should be in the jar. If something was missing "myapp-bootable.jar" should not work, but it does. I even went inside the container and typed the command myself - no luck. Maybe the classloader?
I managed to build successfully the docker image and run it. From your error it seems that you have built a "slim server" (JBoss modules artifacts being resolved from maven local cache). Could you check your pom.xml file and see if you have set jboss-maven-dist and/or jboss-maven-repo plugin options. If that is the case, then remove these options and rebuild the jar. This should work. Thank-you. JF