0 Replies Latest reply on Jul 17, 2019 9:26 AM by Yog Sothoth

    ClassNotFoundException with CDI portable extensions

    Yog Sothoth Newbie

      I've created a CDI 2.0 portable extension (cdi-test-module) with a simple service (MyService and its implementation MyServiceImpl). I then @Inject it into my TestService within a microservice application (tt-app) that i package as uberjar with Thorntail 2.4. This is what i get when i try to run the application on OpenJDK 11.0.2 or Oracle JDK 1.8.0_171:

       

      2019-07-17 15:57:00,531 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) WELD-000119: Not generating any bean definitions from com.acme.service.TestService because of underlying class loading error: Type com.acme.modules.MyService from [Module "deployment.tt-app-0.0.1-SNAPSHOT.jar" from Service Module Loader] not found.  If this is unexpected, enable DEBUG logging to see the full error.
      2019-07-17 15:57:00,531 DEBUG [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) Catching: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class com.acme.service.TestService
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:186)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadSlimAnnotatedType(FastAnnotatedTypeLoader.java:124)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.createContext(FastAnnotatedTypeLoader.java:114)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:103)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:87)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:55)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:52)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
              at java.base/java.lang.Thread.run(Thread.java:834)
              at org.jboss.threads@2.3.2.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
      Caused by: java.lang.NoClassDefFoundError: Lcom/acme/module/MyService;
              at java.base/java.lang.Class.getDeclaredFields0(Native Method)
              at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3062)
              at java.base/java.lang.Class.getDeclaredFields(Class.java:2249)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.SecurityActions.getDeclaredFields(SecurityActions.java:49)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:182)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:176)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:46)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.(BackedAnnotatedType.java:159)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.(BackedAnnotatedType.java:176)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.(BackedAnnotatedType.java:176)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.(BackedAnnotatedType.java:65)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:84)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:79)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$null$0(ReentrantMapBackedComputingCache.java:55)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.WeakLazyValueHolder$1.computeValue(WeakLazyValueHolder.java:35)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.WeakLazyValueHolder.get(WeakLazyValueHolder.java:53)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getCastValue(ReentrantMapBackedComputingCache.java:78)
              at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:177)
              ... 14 more
      Caused by: java.lang.ClassNotFoundException:com.acme.module.MyService from [Module "deployment.tt-app-0.0.1-SNAPSHOT.jar" from Service Module Loader]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
              ... 34 more

       

      Same extension/application code works on Quarkus, Helidon and Kumuluz, so it's definitely not something with my application, but has to do with CDI 2.0 support on TT.