SBT not resolving transitive dependencies in the <Profile> section of POM - scala

If the POM.xml of a dependency has transitive dependencies inside "Profile" section of pom.xml then those dependencies are not resolved by SBT whereas they are resolved by Maven.
Eg:
when the following dependency is included in a project.....
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>0.98.0-hadoop2</version>
</dependency>
...then the following dependencies are not resolved by SBT but are resolved by maven :
hadoop-annotations , hadoop-mapreduce-client-core , hadoop-auth , hadoop-common
Can someone help me understand why this difference in resolution and how can I make SBT include these transient dependencies.
Following is test build.sbt used :
name := "StreamMaker"
version := "1.0"
scalaVersion := "2.10.4"
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
libraryDependencies += "org.apache.hbase" % "hbase-client" % "0.98.0-hadoop2"
net.virtualvoid.sbt.graph.Plugin.graphSettings
Following is the entry in hbase-client's pom.xml :
<profile>
<id>hadoop-2.0</id>
<activation>
<property>
<name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
</dependency>
</dependencies>
</profile>
Depedencies resolved by SBT 0.13.5 :
+-org.apache.hbase:hbase-client:0.98.0-hadoop2
+-com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
+-com.google.guava:guava:12.0.1
| +-com.google.code.findbugs:jsr305:1.3.9
|
+-com.google.protobuf:protobuf-java:2.5.0
+-commons-codec:commons-codec:1.7
+-commons-io:commons-io:2.4
+-commons-lang:commons-lang:2.6
+-commons-logging:commons-logging:1.1.1
+-io.netty:netty:3.6.6.Final
+-junit:junit:4.11
| +-org.hamcrest:hamcrest-core:1.3
|
+-log4j:log4j:1.2.17
+-org.apache.hbase:hbase-protocol:0.98.0-hadoop2
| +-com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
| +-com.google.protobuf:protobuf-java:2.5.0
| +-junit:junit:4.11
| | +-org.hamcrest:hamcrest-core:1.3
| |
| +-log4j:log4j:1.2.17
|
+-org.apache.zookeeper:zookeeper:3.4.5
| +-log4j:log4j:1.2.15 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.16 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.17
| +-org.slf4j:slf4j-api:1.6.1
| +-org.slf4j:slf4j-log4j12:1.6.1
| +-log4j:log4j:1.2.15 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.16 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.17
| +-org.slf4j:slf4j-api:1.6.1
|
+-org.cloudera.htrace:htrace-core:2.04
| +-com.google.guava:guava:12.0.1
| | +-com.google.code.findbugs:jsr305:1.3.9
| |
| +-commons-logging:commons-logging:1.1.1
| +-org.mortbay.jetty:jetty-util:6.1.26
|
+-org.codehaus.jackson:jackson-mapper-asl:1.8.8
+-org.codehaus.jackson:jackson-core-asl:1.8.8
Dependencies resolved by Maven 3.0.4 :
- org.apache.hbase:hbase-client:jar:0.98.0-hadoop2:compile
+- org.apache.hbase:hbase-common:jar:0.98.0-hadoop2:compile
| \- commons-collections:commons-collections:jar:3.2.1:compile
+- org.apache.hbase:hbase-protocol:jar:0.98.0-hadoop2:compile
+- commons-codec:commons-codec:jar:1.7:compile
+- commons-io:commons-io:jar:2.4:compile
+- commons-lang:commons-lang:jar:2.6:compile
+- commons-logging:commons-logging:jar:1.1.1:compile
+- com.google.guava:guava:jar:12.0.1:compile
| \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
+- com.google.protobuf:protobuf-java:jar:2.5.0:compile
+- io.netty:netty:jar:3.6.6.Final:compile
+- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
+- org.cloudera.htrace:htrace-core:jar:2.04:compile
| \- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
+- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.8:compile
| \- org.codehaus.jackson:jackson-core-asl:jar:1.8.8:compile
+- org.apache.hadoop:hadoop-common:jar:2.2.0:compile
| +- commons-cli:commons-cli:jar:1.2:compile
| +- org.apache.commons:commons-math:jar:2.1:compile
| +- xmlenc:xmlenc:jar:0.52:compile
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| +- commons-net:commons-net:jar:3.1:compile
| +- org.mortbay.jetty:jetty:jar:6.1.26:compile
| +- com.sun.jersey:jersey-core:jar:1.9:compile
| +- com.sun.jersey:jersey-json:jar:1.9:compile
| | +- org.codehaus.jettison:jettison:jar:1.1:compile
| | | \- stax:stax-api:jar:1.0.1:compile
| | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
| | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
| | | \- javax.activation:activation:jar:1.1:compile
| | +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
| | \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
| +- commons-el:commons-el:jar:1.0:runtime
| +- net.java.dev.jets3t:jets3t:jar:0.6.1:compile
| +- commons-configuration:commons-configuration:jar:1.6:compile
| | +- commons-digester:commons-digester:jar:1.8:compile
| | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
| | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
| +- org.apache.avro:avro:jar:1.7.4:compile
| | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
| | \- org.xerial.snappy:snappy-java:jar:1.0.4.1:compile
| +- com.jcraft:jsch:jar:0.1.42:compile
| \- org.apache.commons:commons-compress:jar:1.4.1:compile
| \- org.tukaani:xz:jar:1.0:compile
+- org.apache.hadoop:hadoop-auth:jar:2.2.0:compile
+- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.2.0:compile
| +- org.apache.hadoop:hadoop-yarn-common:jar:2.2.0:compile
| | +- org.apache.hadoop:hadoop-yarn-api:jar:2.2.0:compile
| | +- com.google.inject:guice:jar:3.0:compile
| | | +- javax.inject:javax.inject:jar:1:compile
| | | \- aopalliance:aopalliance:jar:1.0:compile
| | +- com.sun.jersey:jersey-server:jar:1.9:compile
| | | \- asm:asm:jar:3.1:compile
| | \- com.sun.jersey.contribs:jersey-guice:jar:1.9:compile
| \- com.google.inject.extensions:guice-servlet:jar:3.0:compile
+- org.apache.hadoop:hadoop-annotations:jar:2.2.0:compile
| \- jdk.tools:jdk.tools:jar:1.7:system
+- com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile
\- junit:junit:jar:4.11:compile
\- org.hamcrest:hamcrest-core:jar:1.3:compile

sbt does not handle maven profiles.
You should add the dependencies (mentioned in given profile) to your sbt file.
name := "StreamMaker"
version := "1.0"
scalaVersion := "2.10.4"
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
libraryDependencies += "org.apache.hbase" % "hbase-client" % "0.98.0-hadoop2"
// Add the dependencies from the active profile.
libraryDependencies ++= Seq("org.apache.hadoop" % "hadoop-mapreduce-client-core" % "2.2.0",
"org.apache.hadoop" % "hadoop-mapreduce-client-jobclient" % "2.2.0",
"org.apache.hadoop" % "hadoop-hdfs" % "2.2.0",
"org.apache.hadoop" % "hadoop-auth" % "2.2.0",
"org.apache.hadoop" % "hadoop-common" % "2.2.0",
"org.apache.hadoop" % "hadoop-client" % "2.2.0",
"org.apache.hadoop" % "hadoop-annotations" % "2.2.0")
net.virtualvoid.sbt.graph.Plugin.graphSettings
See this discussion.
Quoting Josh:
Maven does allow this, but it's kind of bad form. How do you know
which profile was active for deployment? Changing dependencies based
on active profiles is VERY evil to your users. I'd contact that
authors of the project and ask them to find an alternative method.

Related

Find the problematic library in maven project, NoSuchMethodError

I'm trying to run a maven project in eclpise by "Run As / Java application"
I get the error:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.io.output.DeferredFileOutputStream.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/io/File;)V
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.writeRequestBodyToOutputStream(ApacheHttpClient4Engine.java:556)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.buildEntity(ApacheHttpClient4Engine.java:524)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.loadHttpMethod(ApacheHttpClient4Engine.java:423)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:281)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:436)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:195)
at com.allianzWebServices.ws.SubmitDocumentVersionClient.main(SubmitDocumentVersionClient.java:56)
So, obviously there's a library conflict. As I see the DeferredFileOutputStream has more parameters now, so I need to find which library is that it makes this call and update it. But it seems that the call comes from org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine which doesn't seem to exist in my pom and its dependencies or to appear at Dependency Hierarchy. I'm trying to solve this for days, how can I find the root of the problem? My pom is this:
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jettison</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>net.sf.jmimemagic</groupId>
<artifactId>jmimemagic</artifactId>
<version>0.1.5</version>
</dependency>
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.3</version>
</dependency>
Running [mvn dependency:tree] prints:
[INFO] +- commons-configuration:commons-configuration:jar:1.10:compile
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- commons-io:commons-io:jar:2.1:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | \- commons-codec:commons-codec:jar:1.11:compile
[INFO] +- org.glassfish.jersey.core:jersey-client:jar:2.19:compile
[INFO] | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.19:compile
[INFO] | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.19:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b25:compile
[INFO] | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b25:compile
[INFO] | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b25:compile
[INFO] | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b25:compile
[INFO] | \- org.glassfish.hk2:hk2-locator:jar:2.4.0-b25:compile
[INFO] | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.glassfish.jersey.core:jersey-server:jar:2.19:compile
[INFO] | +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.19:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.19:compile
[INFO] | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.19:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.5.1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.5.1:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-databind:jar:2.5.1:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.5.1:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.5.1:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.5.1:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-multipart:jar:2.19:compile
[INFO] | \- org.jvnet.mimepull:mimepull:jar:1.9.5:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-json-jettison:jar:2.19:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-moxy:jar:2.19:compile
[INFO] | \- org.eclipse.persistence:org.eclipse.persistence.moxy:jar:2.6.0:compile
[INFO] | +- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.6.0:compile
[INFO] | | \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.6.0:compile
[INFO] | \- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.19:compile
[INFO] +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] | \- stax:stax-api:jar:1.0.1:compile
[INFO] +- net.sf.jmimemagic:jmimemagic:jar:0.1.5:compile
[INFO] | \- log4j:log4j:jar:1.2.8:runtime
[INFO] \- org.tuckey:urlrewritefilter:jar:4.0.3:compile

Can I exclude nested dependency?

Is it possible to exclude nested dependency ? Consider following dependency:
[info] +-org.apache.ws.commons.axiom:axiom-dom:1.2.13
[info] | +-commons-logging:commons-logging:1.1.1
[info] | +-org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.1
[info] | +-org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1
[info] | +-org.apache.ws.commons.axiom:axiom-api:1.2.13
[info] | | +-commons-logging:commons-logging:1.1.1
[info] | | +-jaxen:jaxen:1.1.3
[info] | | +-org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.1
[info] | | +-org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1
[info] | | +-org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1
[info] | | +-org.apache.james:apache-mime4j-core:0.7.2
I'd like to exclude org.apache.geronimo.specs:geronimo-stax-api_1.0_spec.
Here is what I tried in build.scala
"org.apache.ws.commons.axiom" % "axiom-dom" % axiomVersion excludeAll ExclusionRule(organization = "org.apache.geronimo.specs", name = "geronimo-stax-api_1.0_spec"),
Which didn't work. I guess another option is to make axiom-dom intransitive but it will require me to specify all remaining dependencies manually which is uncool.
According to the SBT manual you have to wrap ExclusionRule into exclude function. Like this:
"org.apache.ws.commons.axiom" % "axiom-dom" % axiomVersion excludeAll(ExclusionRule(organization = "org.apache.geronimo.specs", name = "geronimo-stax-api_1.0_spec"))
or
"org.apache.ws.commons.axiom" % "axiom-dom" % axiomVersion exclude("org.apache.geronimo.specs", "geronimo-stax-api_1.0_spec")

NullPointerException when trying to deploy war to Wildfly 8 from Eclipse

When I try to deploy a war to WildFly directly from Eclipse I get an error. This only happens when I deploy the war from Eclipse, there is no problem, when I copy the war manually into standalone/deployments directory of Wildfly.
Yesterday it worked, no configuration changes in application has been made since then (no new maven dependencies, no changes in web.xml, persistence.xml etc), just some code modifications. There was some Java 8 code added, maybe that could be the problem. But we had Java 8 code in the project before, and it wasn't an issue.
Stacktrace:
12:13:38,595 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 228) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'user-rest.war#mfss-user'
12:13:38,611 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 228) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect
12:13:38,611 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (ServerService Thread Pool -- 228) HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
12:13:38,637 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 228) HHH000397: Using ASTQueryTranslatorFactory
12:13:38,827 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."user-rest.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."user-rest.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20]
Caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213)
at com.google.common.cache.LocalCache.get(LocalCache.java:3933)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:52)
at org.jboss.weld.resources.SharedObjectCache.getTypeClosureHolder(SharedObjectCache.java:98)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedParameter.initTypeClosure(BackedAnnotatedParameter.java:46)
at org.jboss.weld.annotated.slim.backed.BackedAnnotated.<init>(BackedAnnotated.java:19)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedParameter.<init>(BackedAnnotatedParameter.java:39)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedParameter.of(BackedAnnotatedParameter.java:32)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod.initParameters(BackedAnnotatedMethod.java:51)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod.initParameters(BackedAnnotatedMethod.java:27)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedCallable.<init>(BackedAnnotatedCallable.java:34)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod.<init>(BackedAnnotatedMethod.java:38)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod.of(BackedAnnotatedMethod.java:32)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:193)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:186)
at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:154)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:186)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:186)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:66)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:83)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:80)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:52)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:80)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
at org.jboss.weld.bootstrap.BeanDeployer.loadAnnotatedType(BeanDeployer.java:119)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:96)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_20]
... 3 more
12:13:38,832 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "user-rest.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"user-rest.war\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"user-rest.war\".WeldStartService: Failed to start service
Caused by: java.lang.NullPointerException"}}
12:13:38,845 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "user-rest.war" (runtime-name : "user-rest.war")
12:13:38,846 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."user-rest.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."user-rest.war".WeldStartService: Failed to start service
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<alternatives>
</alternatives>
</beans>
persistence.xml:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="mfss-user" transaction-type="JTA">
<description>Default Persistence Unit for mfss-user.</description>
<jta-data-source>java:jboss/datasources/mfss-user</jta-data-source>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.cache.use_second_level_cache" value="false" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
I found that somebody else had a similar problem before, but I can't see any solution there:
https://developer.jboss.org/message/905207
I tried doing all kinds of Project->Clean, MavenProject->Clean, WildflyServer->Clean etc.
I am using Ubuntu 14.04, Wildfly 8, Java 8 (Oracle JDK), Eclipse Luna, Maven
EDIT:
mvn dependency:tree
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # user-rest ---
[INFO] com.domainname.user:user-rest:war:1.0-SNAPSHOT
[INFO] +- com.domainname.user:user-common:jar:1.0-SNAPSHOT:compile
[INFO] | +- com.intdomainname.ihg:constituent-api:jar:14.6.0-SNAPSHOT:compile
[INFO] | | +- commons-lang:commons-lang:jar:2.6:compile (version managed from 2.4)
[INFO] | | +- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.5.2:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
[INFO] | +- com.intdomainname.ihg:constituent-utils:jar:14.6.0-SNAPSHOT:compile
[INFO] | | +- com.intdomainname.qhg.hub.schemas:Messages:jar:14.6.0-SNAPSHOT:compile
[INFO] | | +- commons-vfs:commons-vfs:jar:1.0:compile
[INFO] | | | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] | | +- com.sun.jersey:jersey-client:jar:1.15:compile
[INFO] | | +- com.sun.jersey:jersey-core:jar:1.15:compile
[INFO] | | +- com.sun.jersey:jersey-json:jar:1.15:compile
[INFO] | | | +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] | | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] | | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] | | | | \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | | | \- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] | | +- com.thoughtworks.xstream:xstream:jar:1.4.2:compile
[INFO] | | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | | +- apache-log4j:log4j:jar:1.2.14:compile
[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile
[INFO] | | +- org.apache.activemq:activemq-core:jar:5.5.0:compile
[INFO] | | | +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
[INFO] | | | +- org.apache.activemq:activeio-core:jar:3.1.2:compile
[INFO] | | | +- org.apache.activemq:kahadb:jar:5.5.0:compile
[INFO] | | | +- org.apache.activemq.protobuf:activemq-protobuf:jar:1.1:compile
[INFO] | | | +- org.osgi:org.osgi.core:jar:4.1.0:compile
[INFO] | | | +- org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:compile
[INFO] | | | +- org.springframework:spring-context:jar:3.0.3.RELEASE:compile
[INFO] | | | | +- org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
[INFO] | | | | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | | | +- org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
[INFO] | | | | +- org.springframework:spring-core:jar:3.0.3.RELEASE:compile
[INFO] | | | | +- org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
[INFO] | | | | \- org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
[INFO] | | | +- commons-net:commons-net:jar:2.0:compile
[INFO] | | | \- org.jasypt:jasypt:jar:1.7:compile
[INFO] | | \- org.apache.activemq:activemq-pool:jar:5.5.0:compile
[INFO] | | \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] | \- javax:javaee-api:jar:7.0:compile
[INFO] | \- com.sun.mail:javax.mail:jar:1.5.1:compile (version managed from 1.5.0)
[INFO] | \- javax.activation:activation:jar:1.1.1:compile
[INFO] +- com.domainname.user:user-ejb:jar:1.0-SNAPSHOT:compile
[INFO] | +- com.domainname.user:user-jpa:jar:1.0-SNAPSHOT:compile
[INFO] | | +- org.mockito:mockito-all:jar:1.9.5:compile
[INFO] | | +- com.h2database:h2:jar:1.4.181:compile
[INFO] | | +- org.hibernate:hibernate-entitymanager:jar:4.3.1.Final:compile
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.1.1.GA:compile
[INFO] | | | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | | | +- org.hibernate:hibernate-core:jar:4.3.1.Final:compile
[INFO] | | | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | | | \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] | | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | | | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.4.Final:compile
[INFO] | | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] | | | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | | \- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
[INFO] | | +- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
[INFO] | | \- org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile
[INFO] | +- com.intdomainname.health:identity-api:jar:14.6.0-SNAPSHOT:compile
[INFO] | \- com.intdomainname.health:identity-client-helper:jar:14.6.0-SNAPSHOT:compile
[INFO] | \- apache-codec:commons-codec:jar:1.2:compile
[INFO] +- com.domainname.mfss.common:mfss-common-rest:jar:1.1.0-SNAPSHOT:compile
[INFO] | \- com.domainname.mfss.common:mfss-common-api:jar:1.1.0-SNAPSHOT:compile
[INFO] +- org.jboss.resteasy:jaxrs-api:jar:3.0.6.Final:provided
[INFO] +- org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:jar:1.0.0.Final:provided
[INFO] +- javax.enterprise:cdi-api:jar:1.1:provided
[INFO] | \- javax.inject:javax.inject:jar:1:provided
[INFO] +- org.jboss.resteasy:resteasy-hibernatevalidator-provider:jar:3.0.8.Final:provided
[INFO] | +- org.hibernate:hibernate-validator:jar:5.0.3.Final:provided (version managed from 4.3.1.Final)
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:provided
[INFO] | | \- com.fasterxml:classmate:jar:1.0.0:provided
[INFO] | \- org.jboss.weld.se:weld-se:jar:2.1.0.Final:provided
[INFO] +- org.jboss.resteasy:resteasy-jaxrs:jar:3.0.8.Final:provided
[INFO] | +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:provided
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.1:provided
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.2.1:provided
[INFO] | | \- commons-codec:commons-codec:jar:1.6:provided
[INFO] | +- commons-io:commons-io:jar:2.1:provided
[INFO] | \- net.jcip:jcip-annotations:jar:1.0:provided
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:1.9.5:test
[INFO] | \- org.objenesis:objenesis:jar:1.0:test
[INFO] +- org.powermock:powermock-module-junit4:jar:1.5.4:test
[INFO] | \- org.powermock:powermock-module-junit4-common:jar:1.5.4:test
[INFO] | +- org.powermock:powermock-core:jar:1.5.4:test
[INFO] | \- org.powermock:powermock-reflect:jar:1.5.4:test
[INFO] +- org.powermock:powermock-api-mockito:jar:1.5.4:test
[INFO] | \- org.powermock:powermock-api-support:jar:1.5.4:test
[INFO] \- org.slf4j:slf4j-api:jar:1.7.6:compile
pom.xml without dependencies:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>mfss-user</artifactId>
<groupId>com.domainname.user</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>user-rest</artifactId>
<packaging>war</packaging>
<name>user-rest</name>
<description>REST resources for mfss-user</description>
<dependencies>
...
dependencies
...
</dependencies>
<build>
<finalName>user-rest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>target/apidocs</directory>
</resource>
</webResources>
<archive>
<manifestEntries>
<Dependencies>org.codehaus.jackson.jackson-mapper-asl</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>generate-service-docs</id>
<phase>generate-resources</phase>
<configuration>
<show>private</show>
<doclet>com.hypnoticocelot.jaxrs.doclet.ServiceDoclet</doclet>
<docletArtifact>
<groupId>com.hypnoticocelot</groupId>
<artifactId>jaxrs-doclet</artifactId>
<version>0.0.2</version>
</docletArtifact>
<reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
<useStandardDocletOptions>false</useStandardDocletOptions>
<additionalparam>-apiVersion 1.0 -docBasePath ./ -apiBasePath
services</additionalparam>
<tags>
<tag>
<name>errorResponse</name>
<!-- Http error code for method and type -->
<placement>tm</placement>
<head>Http error code:</head>
</tag>
</tags>
</configuration>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
With your comments above it seems to be the same issue that I've seem several times. I will try to explain you:
You are using maven to build your project and package the WAR. In case of using maven to build and deploy the WAR package, everything is fine and your application runs as expected on the server. In case of using the 'Run on Server' feature of eclipse you always get exceptions which might also differ depending on the state of your project (built with maven, changed some things in eclipse, cleaned the project and built with eclipse, ...) This is probably caused by the incompatibility of the build steps performed by eclipse and those done by maven. I think it's likely that you have some build steps in your pom which are not covered by the eclipse "builders" and are thus missing which results in different errors depending on whether you've built the project with maven prior to the deployment or not and the type of changes you allied.
Sorry if this sounds a bit confusing but its hard to explain this behavior. Best is to try some different workflows like:
build with maven
deploy with maven (everything should work)
undeploy and change some source code
deploy with eclipse (may work)
And analyse your pom(s) if there are some build steps that look like these cannot be covered by eclipse without maven.
I also faced the same issue, it seems that there is some mismatch between the Maven build and the way Eclipse deploy it. The deployment in some way got corrupted and did not allow to re-deploy again and giving NullPointer. I solved it by removing JBoss from Eclipse and adding it back again, updated some of my custom configuration again and started. It worked. Its a workaround but solved my issue.

org.eclipse.core dependency to org.eclipse.runtime suddenly changed

We compile an Adobe CQ project (services, taglib, view, content, etc.) with maven. At some point in time, we introduced the following dependencies:
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>resources</artifactId>
<version>3.3.0-v20070604</version>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>registry</artifactId>
<version>3.3.0-v20070522</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>jobs</artifactId>
<version>3.3.0-v20070423</version>
</dependency>
This resulted in the following dependencies e.g. for org.eclipse.resources (extracted with mvn dependency:tree -Dverbose ):
[INFO] +- org.eclipse.core:resources:jar:3.3.0-v20070604:compile
[INFO] | +- org.eclipse.core:expressions:jar:3.3.0-v20070606-0010:compile
[INFO] | | \- (org.eclipse.core:runtime:jar:3.3.100-v20070530:compile - omitted for duplicate)
[INFO] | +- org.eclipse.core:filesystem:jar:1.1.0-v20070606:compile
[INFO] | | +- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | | +- (org.eclipse.equinox:registry:jar:3.3.0-v20070522:compile - omitted for duplicate)
[INFO] | | \- (org.eclipse:osgi:jar:3.3.0-v20070530:compile - omitted for duplicate)
[INFO] | \- org.eclipse.core:runtime:jar:3.3.100-v20070530:compile
[INFO] | +- (org.eclipse:osgi:jar:3.8.2.v20130124-134944:compile - omitted for duplicate)
[INFO] | +- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | +- (org.eclipse.core:jobs:jar:3.3.0-v20070423:compile - omitted for duplicate)
[INFO] | +- (org.eclipse.equinox:registry:jar:3.3.1:compile - omitted for duplicate)
[INFO] | +- org.eclipse.equinox:preferences:jar:3.2.100-v20070522:compile
[INFO] | | \- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | +- org.eclipse.core:contenttype:jar:3.2.100-v20070319:compile
[INFO] | | +- (org.eclipse.equinox:preferences:jar:3.2.100-v20070522:compile - omitted for duplicate)
[INFO] | | +- (org.eclipse.equinox:registry:jar:3.3.1:compile - omitted for duplicate)
[INFO] | | \- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | \- org.eclipse.equinox:app:jar:1.0.0-v20070606:compile
[INFO] | +- (org.eclipse.equinox:registry:jar:3.3.1:compile - omitted for duplicate)
[INFO] | \- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
Then, from Monday 19th of August 2013 to the 20th of August, the org.eclipse:osgi dependency suddenly changed from 3.3.0-something to 3.8.2-something without any apparent reason (This broke our build quite nastily):
[INFO] +- org.eclipse.core:resources:jar:3.3.0-v20070604:compile
[INFO] | +- org.eclipse.core:expressions:jar:3.3.0-v20070606-0010:compile
[INFO] | | \- (org.eclipse.core:runtime:jar:3.3.100-v20070530:compile - omitted for duplicate)
[INFO] | +- org.eclipse.core:filesystem:jar:1.1.0-v20070606:compile
[INFO] | | +- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | | +- (org.eclipse.equinox:registry:jar:3.3.0-v20070522:compile - omitted for duplicate)
[INFO] | | \- org.eclipse:osgi:jar:3.8.2.v20130124-134944:compile
[INFO] | \- org.eclipse.core:runtime:jar:3.3.100-v20070530:compile
[INFO] | +- (org.eclipse:osgi:jar:3.8.2.v20130124-134944:compile - omitted for duplicate)
[INFO] | +- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | +- (org.eclipse.core:jobs:jar:3.3.0-v20070423:compile - omitted for duplicate)
[INFO] | +- (org.eclipse.equinox:registry:jar:3.3.1:compile - omitted for duplicate)
[INFO] | +- org.eclipse.equinox:preferences:jar:3.2.100-v20070522:compile
[INFO] | | \- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | +- org.eclipse.core:contenttype:jar:3.2.100-v20070319:compile
[INFO] | | +- (org.eclipse.equinox:preferences:jar:3.2.100-v20070522:compile - omitted for duplicate)
[INFO] | | +- (org.eclipse.equinox:registry:jar:3.3.1:compile - omitted for duplicate)
[INFO] | | \- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
[INFO] | \- org.eclipse.equinox:app:jar:1.0.0-v20070606:compile
[INFO] | +- (org.eclipse.equinox:registry:jar:3.3.1:compile - omitted for duplicate)
[INFO] | \- (org.eclipse.equinox:common:jar:3.3.0-v20070426:compile - omitted for duplicate)
We were able to resolve this by adding the dependency explicitely:
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.3.0-v20070530</version>
</dependency>
But still, we do not have any clue, why the dependency changed. Does anybody know the reason or experienced the same issue?
After digging through pom files, .m2/repository/repository.xml and several maven-metadata.xml files, I found the root cause.
The maven-metadata.xml file in Maven repository http://repo.adobe.com for org.eclipse.osgi seems to have been changed on 20th August. For some reason the date of this file was reset now to 11th of July, but the change remains:
The metadata file changed from
<metadata>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.3.0-v20070530</version>
<versioning>
<versions>
...
</versions>
<lastUpdated>20071127073207</lastUpdated>
</versioning>
</metadata>
to
<metadata modelVersion="1.1.0">
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.3.0-v20070530</version>
<versioning>
<latest>3.8.2.v20130124-134944</latest>
<release>3.8.2.v20130124-134944</release>
<versions>
...
</versions>
<lastUpdated>20130711152942</lastUpdated>
</versioning>
</metadata>
Obviously, the latest version was provided after the change, which is now 3.8.2 and not 3.3.0 anymore.
The problem is likely caused by version ranges. These ranges do not even have to be used for the Eclipse artifacts.
Assume you depend on [1,2) and 1.1, and 1.2 are available. At a moment in time, 1.3 is added that has different dependencies. If it finds multiple groupId:artifactId with a different version then it picks the first it finds. Maven follows a breadth first strategy to find dependencies so that you can override it in your top level pom. This is of course very obscure and error prone. A better way is to specify all your app dependencies in one pom so you can ensure valid versions.

Why do I get java.lang.NoClassDefFoundError when I trying to run this code?

I want to map over the characters in a string, but I'm getting runtime errors.
Example:
object Hello {
def hello(c: Char) {
print(c)
}
def main(args: Array[String]) {
"Hello World!".map(hello)
}
}
Trace:
scalac Hello.scala
java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: scala/LowPriorityImplicits
at Hello.main(Hello.scala)
Caused by: java.lang.ClassNotFoundException: scala.LowPriorityImplicits
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
make: *** [test] Error 1
I think that your problem is that scala library is not in your runtime classpath. you must manually add manually.
If you are using tools like maven or sbt, maybe the dependency is marked as provided instead compiled.
If you are not using these tools, add "scala-library.jar" to your library directory
Also seeing this problem because I don't have the right version of Scala. For those who are using IntelliJ, you can add/change the scala SDK under File > Project Structures > Global Libraries:
If you are compiling and running your project in command line, make sure you have the right version of Scala installed too. e.g.:
Check the Scala version installed:
$ scala -version
Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL
Check the build.sbt to have the right version of Scala:
scalaVersion := "2.11.8"
I can confirm the fix is validation dependencies. Or rather what was included by my test library.
For me I upgraded my SpringBoot version which changed my spring-kafka-test version which intern included kafka 2.13.x which finally included scala libs.
I used mvn dependency:tree on my project's build file and searched for '2.12' to find where the old dependency was coming from. Example dependency tree (unrelated dependencies removed). Notice org.apache.kafka:kafka_2.11:jar:0.10.0.0 included as part of my.company.riptide.api:ness-logger:jar:1.0.0 but org.springframework.kafka:spring-kafka-test:jar:2.7.9 includes a newer version org.apache.kafka:kafka_2.13:jar:2.7.2
My solution was to exclude kafaka_2.11 from my ness-logger dependency like this:
<dependency>
<groupId>my.company.riptide.api</groupId>
<artifactId>ness-logger</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
</exclusion>
</exclusions>
</dependency>
Truncated output of mvn dependency:tree:
[INFO] +- my.company.riptide.api:ness-logger:jar:1.0.0:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:2.5.7:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.55:compile
[INFO] | | \- org.hibernate.validator:hibernate-validator:jar:6.2.0.Final:compile
[INFO] | | \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | +- commons-io:commons-io:jar:2.7:compile
[INFO] | +- my.company.eis:ness-logging-package:jar:4.0.1:compile
[INFO] | | +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | | +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] | | | \- org.tukaani:xz:jar:1.5:compile
[INFO] | | +- org.apache.avro:avro-compiler:jar:1.8.2:compile
[INFO] | | | +- org.apache.velocity:velocity:jar:1.7:compile
[INFO] | | | \- joda-time:joda-time:jar:2.7:compile
[INFO] | | +- org.apache.kafka:kafka_2.11:jar:0.10.0.0:compile
[INFO] | | | +- com.101tec:zkclient:jar:0.8:compile
[INFO] | | | \- org.scala-lang.modules:scala-parser-combinators_2.11:jar:1.0.4:compile
[INFO] | | \- com.netflix.hystrix:hystrix-core:jar:1.5.18:compile
[INFO] | | +- com.netflix.archaius:archaius-core:jar:0.4.1:compile
[INFO] | | \- io.reactivex:rxjava:jar:1.3.8:compile
[INFO] | +- org.springframework.boot:spring-boot-loader-tools:jar:2.5.7:compile
[INFO] | | \- org.apache.commons:commons-compress:jar:1.21:compile
[INFO] | \- my.company.riptide.springboot:graceful-shutdown:jar:1.0.2:compile
[INFO] +- org.springframework.kafka:spring-kafka:jar:2.7.9:compile
[INFO] | +- org.springframework:spring-messaging:jar:5.3.13:compile
[INFO] | +- org.springframework:spring-tx:jar:5.3.13:compile
[INFO] | +- org.springframework.retry:spring-retry:jar:1.3.1:compile
[INFO] | | \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | +- org.apache.kafka:kafka-clients:jar:2.7.2:compile
[INFO] | | +- com.github.luben:zstd-jni:jar:1.4.5-6:compile
[INFO] | | +- org.lz4:lz4-java:jar:1.7.1:compile
[INFO] | | \- org.xerial.snappy:snappy-java:jar:1.1.7.7:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] +- junit:junit:jar:4.13.2:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:2.2:compile
[INFO] +- io.cucumber:cucumber-spring:jar:7.0.0:test
[INFO] | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] +- io.cucumber:cucumber-core:jar:7.0.0:test
[INFO] | +- io.cucumber:cucumber-gherkin:jar:7.0.0:test
[INFO] | +- io.cucumber:cucumber-gherkin-messages:jar:7.0.0:test
[INFO] | +- io.cucumber:messages:jar:17.1.1:test
[INFO] | +- io.cucumber:tag-expressions:jar:4.0.2:test
[INFO] | +- io.cucumber:cucumber-expressions:jar:13.0.1:test
[INFO] | +- io.cucumber:datatable:jar:7.0.0:test
[INFO] | +- io.cucumber:cucumber-plugin:jar:7.0.0:test
[INFO] | +- io.cucumber:docstring:jar:7.0.0:test
[INFO] | +- io.cucumber:html-formatter:jar:17.0.0:test
[INFO] | \- io.cucumber:create-meta:jar:6.0.1:test
[INFO] +- org.springframework.kafka:spring-kafka-test:jar:2.7.9:test
[INFO] | +- org.apache.kafka:kafka-clients:jar:test:2.7.2:test
[INFO] | +- org.apache.kafka:kafka-streams:jar:2.7.2:test
[INFO] | | +- org.apache.kafka:connect-json:jar:2.7.2:test
[INFO] | | | \- org.apache.kafka:connect-api:jar:2.7.2:test
[INFO] | | \- org.rocksdb:rocksdbjni:jar:5.18.4:test
[INFO] | +- org.apache.kafka:kafka-streams-test-utils:jar:2.7.2:test
[INFO] | +- org.apache.kafka:kafka_2.13:jar:2.7.2:test
[INFO] | | +- org.apache.kafka:kafka-raft:jar:2.7.2:test
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.13:jar:2.12.5:test
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-csv:jar:2.12.5:test
[INFO] | | +- net.sf.jopt-simple:jopt-simple:jar:5.0.4:compile
[INFO] | | +- com.yammer.metrics:metrics-core:jar:2.2.0:compile
[INFO] | | +- org.scala-lang.modules:scala-collection-compat_2.13:jar:2.2.0:test
[INFO] | | +- org.scala-lang.modules:scala-java8-compat_2.13:jar:0.9.1:test
[INFO] | | +- org.scala-lang:scala-library:jar:2.13.3:compile
[INFO] | | +- org.scala-lang:scala-reflect:jar:2.13.3:test
[INFO] | | +- com.typesafe.scala-logging:scala-logging_2.13:jar:3.9.2:test
[INFO] | | +- org.apache.zookeeper:zookeeper:jar:3.5.9:compile
[INFO] | | | +- org.apache.zookeeper:zookeeper-jute:jar:3.5.9:compile
[INFO] | | | +- org.apache.yetus:audience-annotations:jar:0.5.0:compile
[INFO] | | | \- io.netty:netty-transport-native-epoll:jar:4.1.70.Final:compile
[INFO] | | \- commons-cli:commons-cli:jar:1.4:test
[INFO] | +- org.apache.kafka:kafka_2.13:jar:test:2.7.2:test
[INFO] | \- org.junit.jupiter:junit-jupiter-api:jar:5.7.2:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | \- org.junit.platform:junit-platform-commons:jar:1.7.2:test