Virgo 3.7.2 deployment issues - eclipse-virgo

I'm trying to start migrating to Eclipse Virgo 3.7.2 to move to Spring 4.3.9.
I'm getting a stream of Uses violation errors that we didn't have before with 3.6.4. I had to make some adjustments to migrate the spring schemas and remove the springframework libd which seems to be gone now but nothing to explain the following:
fs-watcher <DE0002E> Installation of plan 'multi-artifact.plan' version '1.0.0' failed. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'multi-artifact.plan-1-org.geppetto.frontend' at version '0.3.9': Cannot resolve: multi-artifact.plan-1-org.geppetto.frontend
Resolver report:
An Import-Package could not be resolved. Resolver error data <Import-Package: org.springframework.web.servlet; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-org.geppetto.frontend_0.3.9>
constraint: <Import-Package: org.springframework.web.servlet; version="0.0.0">
An Import-Package could not be resolved. Resolver error data <Import-Package: org.geppetto.frontend.admin; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-synthetic.context_1.0.0>
constraint: <Import-Package: org.geppetto.frontend.admin; version="0.0.0"> constrained to bundle <multi-artifact.plan-1-org.geppetto.frontend> constrained bundle version range "[0.3.9,0.3.9]"
with attributes {module_scope=multi-artifact.plan-1}
Uses violation: <Import-Package: org.springframework.http.converter.xml; version="[4.3.9.RELEASE,4.3.9.RELEASE]"> in bundle <org.springframework.webmvc_4.3.9.RELEASE[1532366399144]>
Resolver reported uses conflict for import
at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:46)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:359)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:185)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.deploy(HotDeployerFileSystemListener.java:225)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.deployIfNotDeployed(HotDeployerFileSystemListener.java:237)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.onChange(HotDeployerFileSystemListener.java:88)
at org.eclipse.virgo.util.io.FileSystemChecker.notifyListeners(FileSystemChecker.java:380)
at org.eclipse.virgo.util.io.FileSystemChecker.check(FileSystemChecker.java:289)
at org.eclipse.virgo.nano.deployer.hot.WatchTask.run(WatchTask.java:49)
at java.lang.Thread.run(Thread.java:748)
[2018-07-23 19:20:12.041] fs-watcher <DE0003E> Install failed for bundle 'multi-artifact.plan-1-org.geppetto.model' version '0.3.9'.
[2018-07-23 19:20:12.042] fs-watcher <DE0003E> Install failed for bundle 'multi-artifact.plan-1-org.geppetto.core' version '0.3.9'.
[2018-07-23 19:20:12.043] fs-watcher <DE0003E> Install failed for bundle 'multi-artifact.plan-1-org.geppetto.model.neuroml' version '0.3.9'.
[2018-07-23 19:20:12.044] fs-watcher <DE0003E> Install failed for bundle 'multi-artifact.plan-1-org.geppetto.simulation' version '0.3.9'.
[2018-07-23 19:20:12.046] fs-watcher <DE0003E> Install failed for bundle 'multi-artifact.plan-1-org.geppetto.frontend' version '0.3.9'.
[2018-07-23 19:20:12.047] fs-watcher <DE0003E> Install failed for plan 'multi-artifact.plan' version '1.0.0'.
[2018-07-23 19:20:12.048] fs-watcher <DE0500E> Unable to install application from URI 'file:/home/walrus/code/virgo-tomcat-server-3.7.2.RELEASE/pickup/geppetto.plan'. Cannot satisfy constraints for bundle 'multi-artifact.plan-1-org.geppetto.frontend' version '0.3.9'. Cannot resolve: multi-artifact.plan-1-org.geppetto.frontend
Resolver report:
An Import-Package could not be resolved. Resolver error data <Import-Package: org.springframework.web.servlet; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-org.geppetto.frontend_0.3.9>
constraint: <Import-Package: org.springframework.web.servlet; version="0.0.0">
An Import-Package could not be resolved. Resolver error data <Import-Package: org.geppetto.frontend.admin; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-synthetic.context_1.0.0>
constraint: <Import-Package: org.geppetto.frontend.admin; version="0.0.0"> constrained to bundle <multi-artifact.plan-1-org.geppetto.frontend> constrained bundle version range "[0.3.9,0.3.9]"
with attributes {module_scope=multi-artifact.plan-1}
Uses violation: <Import-Package: org.springframework.http.converter.xml; version="[4.3.9.RELEASE,4.3.9.RELEASE]"> in bundle <org.springframework.webmvc_4.3.9.RELEASE[1532366399144]>
Resolver reported uses conflict for import
. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'multi-artifact.plan-1-org.geppetto.frontend' at version '0.3.9': Cannot resolve: multi-artifact.plan-1-org.geppetto.frontend
Resolver report:
An Import-Package could not be resolved. Resolver error data <Import-Package: org.springframework.web.servlet; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-org.geppetto.frontend_0.3.9>
constraint: <Import-Package: org.springframework.web.servlet; version="0.0.0">
An Import-Package could not be resolved. Resolver error data <Import-Package: org.geppetto.frontend.admin; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-synthetic.context_1.0.0>
constraint: <Import-Package: org.geppetto.frontend.admin; version="0.0.0"> constrained to bundle <multi-artifact.plan-1-org.geppetto.frontend> constrained bundle version range "[0.3.9,0.3.9]"
with attributes {module_scope=multi-artifact.plan-1}
Uses violation: <Import-Package: org.springframework.http.converter.xml; version="[4.3.9.RELEASE,4.3.9.RELEASE]"> in bundle <org.springframework.webmvc_4.3.9.RELEASE[1532366399144]>
Resolver reported uses conflict for import
at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:46)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:359)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:185)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.deploy(HotDeployerFileSystemListener.java:225)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.deployIfNotDeployed(HotDeployerFileSystemListener.java:237)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.onChange(HotDeployerFileSystemListener.java:88)
at org.eclipse.virgo.util.io.FileSystemChecker.notifyListeners(FileSystemChecker.java:380)
at org.eclipse.virgo.util.io.FileSystemChecker.check(FileSystemChecker.java:289)
at org.eclipse.virgo.nano.deployer.hot.WatchTask.run(WatchTask.java:49)
at java.lang.Thread.run(Thread.java:748)
[2018-07-23 19:20:12.053] fs-watcher <HD0002E> Hot deploy failed for file 'geppetto.plan'. org.eclipse.virgo.nano.deployer.api.core.DeploymentException: Dependency satisfaction failed
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:362)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:185)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.deploy(HotDeployerFileSystemListener.java:225)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.deployIfNotDeployed(HotDeployerFileSystemListener.java:237)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.onChange(HotDeployerFileSystemListener.java:88)
at org.eclipse.virgo.util.io.FileSystemChecker.notifyListeners(FileSystemChecker.java:380)
at org.eclipse.virgo.util.io.FileSystemChecker.check(FileSystemChecker.java:289)
at org.eclipse.virgo.nano.deployer.hot.WatchTask.run(WatchTask.java:49)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'multi-artifact.plan-1-org.geppetto.frontend' at version '0.3.9': Cannot resolve: multi-artifact.plan-1-org.geppetto.frontend
Resolver report:
An Import-Package could not be resolved. Resolver error data <Import-Package: org.springframework.web.servlet; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-org.geppetto.frontend_0.3.9>
constraint: <Import-Package: org.springframework.web.servlet; version="0.0.0">
An Import-Package could not be resolved. Resolver error data <Import-Package: org.geppetto.frontend.admin; version="0.0.0">. Caused by missing constraint in bundle <multi-artifact.plan-1-synthetic.context_1.0.0>
constraint: <Import-Package: org.geppetto.frontend.admin; version="0.0.0"> constrained to bundle <multi-artifact.plan-1-org.geppetto.frontend> constrained bundle version range "[0.3.9,0.3.9]"
with attributes {module_scope=multi-artifact.plan-1}
Uses violation: <Import-Package: org.springframework.http.converter.xml; version="[4.3.9.RELEASE,4.3.9.RELEASE]"> in bundle <org.springframework.webmvc_4.3.9.RELEASE[1532366399144]>
Resolver reported uses conflict for import
at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:46)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:359)
... 10 common frames omitted
Our project is maven based, and in the pom.xml file we are using the following dependencies:
enter code here
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
Where the spring.version = 4.3.9
Virgo 3.7.2 also comes with springframework 4.3.9 dependencies in repository/ext folder.
The pickpup plan I'm using looks like this:
pick up plan
The artifact that's causing the problem is the last one, org.geppetto.frontend. If I remove it from the plan, and then go to http://localhost:8080/admin/content/artifacts and manually deploy the artifact from there, I don't get the error.
Any ideas on what's going on are much appreciated !

Related

Giving maven dependency error in Spark 2.3

I am building spark 2.3 scala code using maven , giving following error.
error: missing or invalid dependency detected while loading class file SparkSession.class.
This is snippet of pom file, please advise
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.3.0</version>
</dependency>
You might want to check your Java and Scala versions. They should be 1.6 or higher and 2.11 respectively. Or it could also be a mismatch with other dependencies like spark_sql.Make sure you have same version across all dependencies.

Spark sql errors

I try to work with spark-sql but I had the following errors :
error: missing or invalid dependency detected while loading class file
'package.class'. Could not access term annotation in package
org.apache.spark, because it (or its dependencies) are missing. Check
your build definition for missing or conflicting dependencies. (Re-run
with -Ylog-classpath to see the problematic classpath.) A full
rebuild may help if 'package.class' was compiled against an
incompatible version of org.apache.spark. warning: Class
org.apache.spark.annotation.InterfaceStability not found - continuing
with a stub. error: missing or invalid dependency detected while
loading class file 'SparkSession.class'. Could not access term
annotation in package org.apache.spark, because it (or its
dependencies) are missing. Check your build definition for missing or
conflicting dependencies. (Re-run with -Ylog-classpath to see the
problematic classpath.) A full rebuild may help if
'SparkSession.class' was compiled against an incompatible version of
org.apache.spark.
My configuration :
Scala 2.11.8
Spark-core_2.11-2.1.0
Spark-sql_2.11-2.1.0
Note: I use SparkSession.
After dig into the error message, I know how to solve this kind of errors.
For example:
Error - Symbol 'term org.apache.spark.annotation' is missing... A full rebuild may help if 'SparkSession.class' was compiled against an incompatible version of org.apache.spark
Open SparkSession.class, search "import org.apache.spark.annotation.", you will find import org.apache.spark.annotation.{DeveloperApi, Experimental, InterfaceStability}. It's sure that these classes is missing in classpath. You'll need to find the artifact which conclude these classes.
So open https://search.maven.org and search with c:"DeveloperApi" AND g:"org.apache.spark", you will find the missing artifact is spark-tags as #Prakash answered.
In my situation, just add dependencies spark-catalyst and spark-tags in pom.xml works.
But it's weird that why maven not auto resolve transitive dependencies here?
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
If I use the above depencency, only spark-core_2.11-2.2.0.jar is in maven dependency; While if I change version to 2.1.0 or 2.3.0, all transitive dependencies will be there.
You need to include following artifacts to avoid the dependency issues.
spark-unsafe_2.11-2.1.1
spark-tags_2.11-2.1.1

Correct configuration for Maven to load Native Hadoop Libraries

I am trying to run a Mahout project which I wrote in Eclipse with the Mahout and Hadoop libraries. It loads in a dataset and runs the FPGrowth algorithm. I set up the following Run configuration to run the project:
mvn exec:java -Dexec.mainClass=com.patternmatching.RecommendApp.TopPatternMatches
After running the program, I get the following error message:
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
I researched this issue, and realized that the Native hadoop libraries have to either be compiled, or downloaded from Apache (Hadoop "Unable to load native-hadoop library for your platform" warning) . I downloaded the libraries on a Cloudera Quickstart VM, on which I set up Mahout and Maven, along with my project package. After running it in cloudera, I get the same error. I also ran the Hadoop checknative -a command, which verifies that the Native libraries are available:
[root#quickstart /]# hadoop checknative -a
16/10/22 19:32:16 INFO bzip2.Bzip2Factory: Successfully loaded & initialized native-bzip2 library system-native
16/10/22 19:32:16 INFO zlib.ZlibFactory: Successfully loaded & initialized native-zlib library
Native library checking:
hadoop: true /usr/lib/hadoop/lib/native/libhadoop.so.1.0.0
zlib: true /lib64/libz.so.1
snappy: true /usr/lib/hadoop/lib/native/libsnappy.so.1
lz4: true revision:99
bzip2: true /lib64/libbz2.so.1
openssl: true /usr/lib64/libcrypto.so
The output of the command verifies that the libraries are available, but are not being correctly loaded into the program or classpath. I am not sure how to configure Maven so that it loads in the Hadoop native libraries when running the program. This is the dependencies section of the Maven pom.xml file:
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>3.0.0-alpha1</version>
</dependency>
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
and the command I run to execute my Mahout java program is
mvn exec:java -Dexec.mainClass=com.patternmatching.RecommendApp.TopPatternMatches
How can I configure Maven to see these libraries so they are used in the program?

NoClassDefFoundError - datastax java driver for Cassandra

I am currently unable to connect to my cassandra database using the datastax driver. I am getting the following error:
com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered (java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet;)
at com.datastax.driver.core.Connection$Dispatcher.exceptionCaught(Connection.java:556)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet;
at com.datastax.driver.core.DataType.<clinit>(DataType.java:144)
at com.datastax.driver.core.Codec.<clinit>(Codec.java:31)
However, I have included the guava artefact in my pom.xml as follows:
<!-- Datastax driver -->
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>1.0.4</version>
</dependency>
<!-- Cassandra -->
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>1.2.9</version>
</dependency>
<!-- guava --<
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
Full pom.xml: http://pastebin.ubuntu.com/6358603/
Am I missing a dependency?
According to its POM, version 1.0.4 of cassandra-driver-core uses version 14.0.1 of Guava, not version 15.0. I'm guessing you are seeing a version clash. Even if that version difference is not the cause of this problem, it might cause other problems.
You do not usually need to include transitive dependencies in POMs, Maven takes care of them for you. Or does your own code use Guava itself?
Based on the advice of this question: no such method error: ImmutableList.copyOf()
I had to exclude the google collections jar:
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-core</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
</exclusion>
</exclusions>
</dependency>

Logging with embedded Jetty and Tapestry

I have a war web application which is using Tapestry framework. It uses slf4j + log4j and works well.
I also have a simple server application with embedded jetty 8 which I am using to deploy the war.
I would like to use slf4j + log4j in the server as well.
Therefore I add the slf4j and log4j dependency to my server pom.xml:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
I get:
SLF4J: Class path contains multiple SLF4J bindings.<br/>
SLF4J: Found binding in [jar:file:/tmp/jetty-0.0.0.0-8080-web-app-0.0.1.war-_-any-/webapp WEB-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/martin/monitoring-gui/trunk/release/target/release-0.0.1-webgui-distribution/release-0.0.1/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Fair enough, Tapestry dependency automatically includes slf4j-log4j12 and log4j. So I add following to my webapp pom.xml tapestry-core section:
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
Now, the actual binding and logger should only be present in the server application.
However upon server start I get:
Exception in thread "main" java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/eclipse/jetty/webapp/WebAppClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type taticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory; used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:299)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at org.apache.tapestry5.TapestryFilter.<init>(TapestryFilter.java:56)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at org.eclipse.jetty.servlet.ServletContextHandler$Context.createFilter(ServletContextHandler.java:1051)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:104)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:763)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:282)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
...
going all the way to my jetty Server.start() call;
What am I missing?
You have a dependency problem. Instead of using exclusion all the time I see the dependency tree and reorder the tags inside pom.xml. The rule here seams that the first appearance of the dependency wins. So when you want that a inherited dependency is omitted by another one, just move the dependency tag before the one you want the inherited dependency omitted.
That makes the pom more readable and also controls which version of the dependencies in the trees are used. In only rare cases I have to use the tag.
The problem is that you have two versions of slf4j-log4j12 on your classpath. By the looks of it you are managing to exclude the later version in stead of the older one. Slf4j is complaining about the fact it is expecting a newer version than the one it is finding.
It seems to me that the 1.6.1 version makes it onto your classpath though your embedded jetty server. Have you setup your jetty dependency through maven as well? If so, add the exclude to your jetty dependency too. Either way, you need to inspect your classpath and resolve the conflicting versions one way or the other
Alright, thanks for help joostschouten and user2424794. I've got it working.
The mvn dependency:tree revealed, that other web app's dependency: qpid-client imported another slf4j-api to the war.
So another exclusion was necessary:
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-client</artifactId>
<version>0.22</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
For the record, the tapestry-core dependency:
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
<version>${tapestry-release-version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
The only problem left is that the war wouldn't compile without the slf4j-api, therefore I add it as war dependency for the compilation, not for the linking - maven's provided scope:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<scope>provided</scope>
</dependency>
Of course, the slf4j-api , slf4j-log4j12 and log4j are added as dependencies for the server, which 'provides' it to the war application.
Now everything compiles, runs and logs just fine.

Resources