Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2468

Uber JAR: weld throws massive amount of java.lang.ClassNotFoundException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 3.0.3.Final
    • Java SE Support
    • None
    • Hide
      1. Clone the project from https://github.com/sdudziak/logreader/tree/feature/unified-os-service-app-architecture
      2. run: gradle wrapper
      3. run: ./gradlew build
      4. run: ./gradlew run ---- to see the expected output (countdown from 10 to 0)
      5. run: cd build/lib && java -jar log-reader-1.0.jar ---- to see errors
      Show
      Clone the project from https://github.com/sdudziak/logreader/tree/feature/unified-os-service-app-architecture run: gradle wrapper run: ./gradlew build run: ./gradlew run ---- to see the expected output (countdown from 10 to 0) run: cd build/lib && java -jar log-reader-1.0.jar ---- to see errors

      I'm creating application which have to be run as a system service (win10/linux, whatever)
      When I start the application using "gradlew run" command everything is fine. But when I'm starting to build system service or even Uber JAR, weld cannot discover dozens of classes, and throws a lot of exceptions:

      Windows 10 service debug log:

      C:\Users\szdud\Documents\Projects\Java\logreader\build\windows-service> .\LogReader.exe //TS//LogReader start
      System coudn't find path given.
      Unable to create logger at ''
      Exception in thread "main" java.lang.NoClassDefFoundError: com/netps/build/LogReaderService
      Caused by: java.lang.ClassNotFoundException: com.netps.build.LogReaderService
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
          at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
      [2018-03-03 23:42:11] [error] [13612] FindClass com/netps/build/LogReaderService failed
      [2018-03-03 23:42:11] [error] [ 3724] Failed to start Java
      [2018-03-03 23:42:11] [error] [ 3724] ServiceStart returned 4
      [2018-03-03 23:42:11] [error] [ 3724] Commons Daemon procrun failed with exit value: 3 (Failed to run service as console application)
      
      Failed to run service as console application
      

      Windows uber JAR log:

      [2018-03-05 10:52:10.226][DEBUG][main] logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
      [2018-03-05 10:52:10.230][INFO ][main] Version - WELD-000900: 3.0.3 (Final)
      [2018-03-05 10:52:10.251][DEBUG][main] Bootstrap - WELD-ENV-000030: Cannot load class using the ResourceLoader: org.jboss.jandex.Index
      [2018-03-05 10:52:10.419][DEBUG][main] DefaultBeanArchiveScanner - Resolved bean archive reference: /var/www/netps/logreader/build/libs/log-
      reader-all-1.0.jar for URL: jar:file:/var/www/netps/logreader/build/libs/log-reader-all-1.0.jar!/META-INF/beans.xml
      [2018-03-05 10:52:10.420][DEBUG][main] Bootstrap - WELD-ENV-000032: Processing bean archive reference: /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar
      [2018-03-05 10:52:10.420][DEBUG][main] FileSystemBeanArchiveHandler - Handle path: /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar
      [2018-03-05 10:52:10.420][DEBUG][main] FileSystemBeanArchiveHandler - Handle archive file: /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar
      [2018-03-05 10:52:10.440][DEBUG][main] Bootstrap - WELD-ENV-000039: Bean archive reference /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar handled by org.jboss.weld.environment.deployment.discovery.File
      SystemBeanArchiveHandler@528c868
      [2018-03-05 10:52:10.443][DEBUG][main] Bootstrap - WELD-ENV-000024: Archive isolation enabled - creating multiple isolated bean archives if needed
      [2018-03-05 10:52:10.446][DEBUG][main] BootstrapTracker - START bootstrap 
      [2018-03-05 10:52:10.446][DEBUG][main] BootstrapTracker - START bootstrap > startContainer 
      [2018-03-05 10:52:10.454][DEBUG][main] Configuration - WELD-001902: Following configuration was detected and applied: {org.jboss.weld.executor.threadPoolType=COMMON, org.jboss.weld.construction.relaxed=true, org.j
      boss.weld.bootstrap.allowOptimizedCleanup=true}
      [2018-03-05 10:52:10.455][DEBUG][main] BootstrapTracker - START bootstrap > startContainer > initServices 
      [2018-03-05 10:52:10.475][DEBUG][main] Bootstrap - Using Weld modules: []
      [2018-03-05 10:52:10.496][DEBUG][main] Bootstrap - Using instantiator: org.jboss.weld.bean.proxy.UnsafeProxyInstantiator
      [2018-03-05 10:52:10.510][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer > initServices (55 ms)
      [2018-03-05 10:52:10.510][INFO ][main] Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
      [2018-03-05 10:52:10.537][DEBUG][main] BootstrapTracker - START bootstrap > startContainer > builtinContexts 
      [2018-03-05 10:52:10.591][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%ApplicationContext
      [2018-03-05 10:52:10.594][DEBUG][main] Reflection - WELD-000601: interface javax.inject.Singleton is missing @Target. Weld will use this annotation, however this may make the application unportable.
      [2018-03-05 10:52:10.595][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%SingletonContext
      [2018-03-05 10:52:10.597][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%BoundSessionContext
      [2018-03-05 10:52:10.599][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%BoundConversationContext
      [2018-03-05 10:52:10.600][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%BoundRequestContext
      [2018-03-05 10:52:10.600][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%RequestContext
      [2018-03-05 10:52:10.602][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%DependentContext
      [2018-03-05 10:52:10.602][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer > builtinContexts (64 ms)
      [2018-03-05 10:52:10.605][DEBUG][main] BootstrapTracker - START bootstrap > startContainer > readDeploymentStructure 
      [2018-03-05 10:52:10.621][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [javax.enterprise.inject.spi.BeanManager] with qualifiers [@Default]
      [2018-03-05 10:52:10.621][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [org.jboss.weld.manager.BeanManagerImpl] with qualifiers [@Default]
      [2018-03-05 10:52:10.622][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer > readDeploymentStructure (16 ms)
      [2018-03-05 10:52:10.622][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer (176 ms)
      [2018-03-05 10:52:10.623][DEBUG][main] BootstrapTracker - START bootstrap > startInitialization 
      [2018-03-05 10:52:10.652][DEBUG][main] Bootstrap - WELD-000106: Bean: Extension [class org.jboss.weld.bootstrap.WeldExtension] with qualifiers [@Default]; n/a
      [2018-03-05 10:52:10.652][DEBUG][main] Bootstrap - WELD-000168: Extension bean deployed: Extension [class org.jboss.weld.bootstrap.WeldExtension] with qualifiers [@Default]; n/a
      [2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000106: Bean: Extension [class org.jboss.weld.environment.se.WeldSEBeanRegistrant] with qualifiers [@Default]; jar:file:/var/www/netps/logreader/build/libs/l
      og-reader-all-1.0.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998]
      [2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000168: Extension bean deployed: Extension [class org.jboss.weld.environment.se.WeldSEBeanRegistrant] with qualifiers [@Default]; jar:file:/var/www/netps/log
      reader/build/libs/log-reader-all-1.0.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998]
      [2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [javax.enterprise.inject.spi.BeanManager] with qualifiers [@Default]
      [2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [org.jboss.weld.manager.BeanManagerImpl] with qualifiers [@Default]
      [2018-03-05 10:52:10.666][DEBUG][main] BootstrapTracker - START bootstrap > startInitialization > BeforeBeanDiscovery 
      [2018-03-05 10:52:10.695][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.bootstrap.WeldExtension@d78795 for [BackedAnnotatedType] public @Vetoed @Interceptor 
      @ActivateRequestContext @Priority class org.jboss.weld.contexts.activator.ActivateRequestContextInterceptor
      [2018-03-05 10:52:10.697][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.bootstrap.WeldExtension@d78795 for [BackedAnnotatedType] public @Vetoed @Interceptor 
      @ActivateRequestContext @Priority class org.jboss.weld.contexts.activator.CdiRequestContextActivatorInterceptor
      [2018-03-05 10:52:10.701][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998 for [BackedAnnotatedType] public @Vetoed
       @ApplicationScoped class org.jboss.weld.environment.se.beans.ParametersFactory
      [2018-03-05 10:52:10.704][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998 for [BackedAnnotatedType] public @Decora
      tor class org.jboss.weld.environment.se.threading.RunnableDecorator
      [2018-03-05 10:52:10.706][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998 for [BackedAnnotatedType] public @Vetoed
       @Interceptor @ActivateThreadScope @Priority class org.jboss.weld.environment.se.contexts.activators.ActivateThreadScopeInterceptor
      [2018-03-05 10:52:10.706][DEBUG][main] BootstrapTracker -   END bootstrap > startInitialization > BeforeBeanDiscovery (40 ms)
      [2018-03-05 10:52:10.799][INFO ][ForkJoinPool.commonPool-worker-15] Bootstrap - WELD-000119: Not generating any bean definitions from org.jboss.weld.servlet.api.helpers.ForwardingServletListener because of underly
      ing class loading error: Type javax.servlet.ServletContextListener not found.  If this is unexpected, enable DEBUG logging to see the full error.
      [2018-03-05 10:52:10.800][DEBUG][ForkJoinPool.commonPool-worker-15] Bootstrap - Catching
      org.jboss.weld.resources.spi.ResourceLoadingException: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
          at org.jboss.weld.environment.deployment.WeldResourceLoader.classForName(WeldResourceLoader.java:44) ~[log-reader-all-1.0.jar:?]
          at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadClass(AnnotatedTypeLoader.java:82) [log-reader-all-1.0.jar:?]
          at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:62) [log-reader-all-1.0.jar:?]
          at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:87) [log-reader-all-1.0.jar:?]
          at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:55) [log-reader-all-1.0.jar:?]
          at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:52) [log-reader-all-1.0.jar:?]
          at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62) [log-reader-all-1.0.jar:?]
          at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55) [log-reader-all-1.0.jar:?]
          at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431) [?:?]
          at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:283) [?:?]
          at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603) [?:?]
          at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) [?:?]
      ...
      

      I was looking for the solution on https://stackoverflow.com/questions/49090102/java-win-service-with-procrun-and-cdi-weld but didn't get any clue there.

              Unassigned Unassigned
              sdudziak Szymon Dudziak (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: