Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-643

Running WF-Swarm as fat-jar fails with NoClassDefFoundError but works when running with mvn wildfly-warm:run

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: 2016.8
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Sprint:
      2016.10

      Description

      The example from the CiA 2nd ed book about WF-Swarm and Camel fails with an error. The source code is here:
      https://github.com/camelinaction/camelinaction2/tree/master/chapter7/wildfly-swarm

      There is a readme file explaining how to build and run the example.

      It works with: mvn wildfly-swarm:run

      But fails when running as far-jar with: java -jar target/hello-swarm.jar

      You get a deployment error with some class loading error:

      2016-08-31 15:04:50,824 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."hello.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."hello.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "hello.war"
             	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
             	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
             	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
             	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
             	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
             	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
             	at org.apache.camel.cdi.CdiCamelEnvironment.hasBundleContext(CdiCamelEnvironment.java:56)
             	at org.apache.camel.cdi.CdiCamelEnvironment.<init>(CdiCamelEnvironment.java:33)
             	at org.apache.camel.cdi.CdiCamelExtension.<init>(CdiCamelExtension.java:85)
             	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
             	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
             	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
             	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
             	at java.lang.Class.newInstance(Class.java:438)
             	at org.jboss.as.weld.deployment.WeldPortableExtensions.tryRegisterExtension(WeldPortableExtensions.java:53)
             	at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadAttachments(WeldPortableExtensionProcessor.java:121)
             	at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.deploy(WeldPortableExtensionProcessor.java:81)
             	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
             	... 5 more
      Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module "org.apache.camel.component.cdi:main" from BootModuleLoader@1c72da34 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap:main), ClasspathModuleFinder, ContainerModuleFinder(swarm.container:main), ApplicationModuleFinder(swarm.application:main), FlattishApplicationModuleFinder(swarm.application:flattish)]]
             	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
             	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
             	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
             	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
             	... 17 more
      
      2016-08-31 15:04:50,833 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "hello.war")) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"hello.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"hello.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"hello.war\"
          Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
          Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module \"org.apache.camel.component.cdi:main\" from BootModuleLoader@1c72da34 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap:main), ClasspathModuleFinder, ContainerModuleFinder(swarm.container:main), ApplicationModuleFinder(swarm.application:main), FlattishApplicationModuleFinder(swarm.application:flattish)]]"}}
      2016-08-31 15:04:50,835 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "hello.war" was rolled back with the following failure message:
      {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"hello.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"hello.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"hello.war\"
          Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
          Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module \"org.apache.camel.component.cdi:main\" from BootModuleLoader@1c72da34 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap:main), ClasspathModuleFinder, ContainerModuleFinder(swarm.container:main), ApplicationModuleFinder(swarm.application:main), FlattishApplicationModuleFinder(swarm.application:flattish)]]"}}
      2016-08-31 15:04:50,894 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0028: Stopped deployment hello.war (runtime-name: hello.war) in 58ms
      2016-08-31 15:04:50,895 INFO  [org.jboss.as.controller] (main) WFLYCTL0183: Service status report
      WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."hello.war".POST_MODULE
      
      2016-08-31 15:04:50,897 ERROR [stderr] (main) Exception in thread "main" java.lang.reflect.InvocationTargetException
      2016-08-31 15:04:50,898 ERROR [stderr] (main)  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2016-08-31 15:04:50,898 ERROR [stderr] (main)  	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      2016-08-31 15:04:50,898 ERROR [stderr] (main)  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      2016-08-31 15:04:50,898 ERROR [stderr] (main)  	at java.lang.reflect.Method.invoke(Method.java:483)
      2016-08-31 15:04:50,898 ERROR [stderr] (main)  	at org.wildfly.swarm.bootstrap.Main.invoke(Main.java:86)
      2016-08-31 15:04:50,898 ERROR [stderr] (main)  	at org.wildfly.swarm.bootstrap.Main.run(Main.java:50)
      2016-08-31 15:04:50,899 ERROR [stderr] (main)  	at org.wildfly.swarm.bootstrap.Main.main(Main.java:45)
      2016-08-31 15:04:50,899 ERROR [stderr] (main) Caused by: org.wildfly.swarm.container.DeploymentException: WFSWARM0007: Deployment failed: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"hello.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"hello.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"hello.war\"
      2016-08-31 15:04:50,899 ERROR [stderr] (main)     Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
      2016-08-31 15:04:50,899 ERROR [stderr] (main)     Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module \"org.apache.camel.component.cdi:main\" from BootModuleLoader@1c72da34 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap:main), ClasspathModuleFinder, ContainerModuleFinder(swarm.container:main), ApplicationModuleFinder(swarm.application:main), FlattishApplicationModuleFinder(swarm.application:flattish)]]"}}
      2016-08-31 15:04:50,899 ERROR [stderr] (main)  	at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:203)
      2016-08-31 15:04:50,899 ERROR [stderr] (main)  	at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:77)
      2016-08-31 15:04:50,900 ERROR [stderr] (main)  	at org.wildfly.swarm.Swarm.deploy(Swarm.java:374)
      2016-08-31 15:04:50,900 ERROR [stderr] (main)  	at org.wildfly.swarm.Swarm.main(Swarm.java:498)
      2016-08-31 15:04:50,900 ERROR [stderr] (main)  	... 7 more
      ^C2016-08-31 15:05:25,182 INFO  [org.jboss.as.server] (Thread-4) WFLYSRV0220: Server shutdown has been requested.
      2016-08-31 15:05:25,204 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0008: Undertow HTTP listener default suspending
      2016-08-31 15:05:25,205 INFO  [org.jboss.gravia.runtime] (MSC service thread 1-6) Stopped: Module[gravia-container-wildfly-extension:1.3.1]
      2016-08-31 15:05:25,206 INFO  [org.jboss.gravia.runtime] (MSC service thread 1-6) Uninstalled: Module[gravia-container-wildfly-extension:1.3.1]
      2016-08-31 15:05:25,208 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0007: Undertow HTTP listener default stopped, was bound to [0:0:0:0:0:0:0:0]:8080
      2016-08-31 15:05:25,209 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0019: Host default-host stopping
      2016-08-31 15:05:25,212 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0004: Undertow 1.3.15.Final stopping
      2016-08-31 15:05:25,216 INFO  [org.jboss.gravia.runtime] (MSC service thread 1-6) Runtime released: org.wildfly.extension.gravia.service.WildFlyRuntime@23d3aff2
      2016-08-31 15:05:25,221 INFO  [org.jboss.weld.Bootstrap] (Thread-3) WELD-ENV-002001: Weld SE container STATIC_INSTANCE shut down
      2016-08-31 15:05:25,223 INFO  [stdout] (Thread-3) Weld SE container STATIC_INSTANCE shut down by shutdown hook
      2016-08-31 15:05:25,223 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0050: WildFly Core 2.0.10.Final "Kenny" stopped in 33ms
      

      The class that has the NoClassDefFoundException: org/apache/camel/core/osgi/utils/BundleContextUtils is located in the camel-core JAR. Not sure why camel-cdi cannot find this class, and why it works when running using the mvn plugin instead.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                davsclaus Claus Ibsen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: