Home > front end >  java.lang.NoClassDefFoundError: scala/collection/convert/DecorateAsScala but scala-library in pom.xm
java.lang.NoClassDefFoundError: scala/collection/convert/DecorateAsScala but scala-library in pom.xm

Time:11-05

I am adding my first Swagger description to a trivial, working servlet built using RestEasy and deployed to a server using the current version of JBoss EAP. After adding many dependencies from sample pom.xml's including

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.13.7</version>
        </dependency>

I get the following stack trace. Please note I have also tried other versions of scala with the same result

1:17:18,353 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 100) MSC000001: Failed to start service jboss.deployment.unit."PamHelper.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."PamHelper.war".undertow-deployment: java.lang.NoClassDefFoundError: scala/collection/convert/DecorateAsScala
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
        at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.lang.NoClassDefFoundError: scala/collection/convert/DecorateAsScala
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
        at java.base/java.lang.Class.privateGetPublicMethods(Class.java:3191)
        at java.base/java.lang.Class.getMethods(Class.java:1904)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.spi.metadata.ResourceBuilder.fromAnnotations(ResourceBuilder.java:861)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.spi.metadata.ResourceBuilder.getRootResourceFromAnnotations(ResourceBuilder.java:830)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.<init>(POJOResourceFactory.java:38)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:79)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:485)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:282)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:89)
        at org.jboss.resteasy.resteasy-jaxrs@3.9.3.SP1-redhat-00001//org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:25)
        at io.undertow.servlet@2.0.28.SP1-redhat-00001//io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
        at io.undertow.servlet@2.0.28.SP1-redhat-00001//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:217)
        at io.undertow.servlet@2.0.28.SP1-redhat-00001//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186)
        at io.undertow.servlet@2.0.28.SP1-redhat-00001//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet@2.0.28.SP1-redhat-00001//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
        at io.undertow.servlet@2.0.28.SP1-redhat-00001//io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
        at org.wildfly.extension.undertow@7.3.0.GA-redhat-00004//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
        ... 8 more
Caused by: java.lang.ClassNotFoundException: scala.collection.convert.DecorateAsScala from [Module "deployment.PamHelper.war" 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)
        ... 33 more

I am taking my dependencies from postings that discuss using Swagger with RestEasy under JBoss, but this still seems to be a dependency issue. I don't see another scala dependency - what other dependency is needed for DecorateAsScala?

CodePudding user response:

scala.collection.convert.DecorateAsScala does not exist in Scala 2.13.7. You may want to try 2.12.15. Or even 2.11.12 if you run into similar errors then.

I wonder if you actually need a Scala dependency. None of the things you name seem to require Scala. Unless you want to use Swagger for Scala, but I guess that's not the case. Either way, if it is a transitive dependency Maven should automatically download the correct version if you don't declare it yourself.

  • Related