java.lang.NoClassDefFoundError when trying to run JUnit 5 tests - eclipse

I have the following error when trying to run a simple JUnit 5 test (eclipse):
java.lang.NoClassDefFoundError: org/junit/platform/commons/PreconditionViolationException
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createFilteredTest(JUnit5TestLoader.java:70)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createTest(JUnit5TestLoader.java:64)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.loadTests(JUnit5TestLoader.java:53)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:525)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.commons.PreconditionViolationException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Here is my pom.xml:
<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>
<groupId>Test</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
I've tried some suggestions on similar questions like this, this github issue and others, but without success. I'm still learning JUnit so I may be forgetting something obvious.

Nevermind, I forgot to add the JUnit 5 library to my build path, now it works perfectly.

Related

Scala 2.12.8 macros with Maven

I'm trying to use Scala Macros with Maven!
I found an old answer on Stackoverflow HERE but seems it doesn't work in my case.
I got an error at compile time even if in my code there isn't any macros!
Searching on google i didn't found a lot documentation about this feature used with maven. Unfortunately we are working on a legacy java project and for this reason we can't migrate to SBT.
I got the following error:
Error:scalac: Error: scala.tools.nsc.typechecker.Namers$Namer.enterDefaultGetters(Lscala/reflect/internal/Symbols$Symbol;Lscala/reflect/internal/Trees$DefDef;Lscala/collection/immutable/List;Lscala/collection/immutable/List;)V
java.lang.NoSuchMethodError: scala.tools.nsc.typechecker.Namers$Namer.enterDefaultGetters(Lscala/reflect/internal/Symbols$Symbol;Lscala/reflect/internal/Trees$DefDef;Lscala/collection/immutable/List;Lscala/collection/immutable/List;)V
at org.scalamacros.paradise.typechecker.Namers$Namer.$anonfun$finishSymbolNotExpandee$1(Namers.scala:282)
at org.scalamacros.paradise.typechecker.Namers$Namer.savingLock$1(Namers.scala:215)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbolNotExpandee(Namers.scala:219)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbolNotExpandee$(Namers.scala:211)
at org.scalamacros.paradise.typechecker.Namers$$anon$1.finishSymbolNotExpandee(Namers.scala:13)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbol(Namers.scala:183)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbol$(Namers.scala:166)
at org.scalamacros.paradise.typechecker.Namers$$anon$1.finishSymbol(Namers.scala:13)
at org.scalamacros.paradise.typechecker.Namers$Namer.dispatch$1(Namers.scala:35)
at org.scalamacros.paradise.typechecker.Namers$Namer.enterSym(Namers.scala:41)
at org.scalamacros.paradise.typechecker.Namers$Namer.enterSym$(Namers.scala:23)
at org.scalamacros.paradise.typechecker.Namers$$anon$1.enterSym(Namers.scala:13)
at org.scalamacros.paradise.typechecker.AnalyzerPlugins$MacroPlugin$.pluginsEnterSym(AnalyzerPlugins.scala:36)
at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$15.custom(AnalyzerPlugins.scala:461)
at scala.tools.nsc.typechecker.AnalyzerPlugins.$anonfun$invoke$3(AnalyzerPlugins.scala:403)
at scala.tools.nsc.typechecker.AnalyzerPlugins.invoke(AnalyzerPlugins.scala:403)
at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsEnterSym(AnalyzerPlugins.scala:455)
at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsEnterSym$(AnalyzerPlugins.scala:453)
at scala.tools.nsc.Global$$anon$1.pluginsEnterSym(Global.scala:458)
at scala.tools.nsc.typechecker.Namers$Namer.enterSym(Namers.scala:261)
at scala.tools.nsc.typechecker.Namers$Namer.enterSyntheticSym(Namers.scala:801)
at scala.tools.nsc.typechecker.Namers$Namer.$anonfun$addCopyMethod$1(Namers.scala:1749)
at scala.tools.nsc.typechecker.Namers$Namer.addCopyMethod(Namers.scala:1749)
at scala.tools.nsc.typechecker.Namers$Namer.$anonfun$templateSig$6(Namers.scala:1168)
at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:1162)
at scala.tools.nsc.typechecker.Namers$Namer.classSig(Namers.scala:1187)
at scala.tools.nsc.typechecker.Namers$Namer.memberSig(Namers.scala:1798)
at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1761)
at scala.tools.nsc.typechecker.Namers$Namer$MonoTypeCompleter.completeImpl(Namers.scala:840)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete(Namers.scala:1958)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete$(Namers.scala:1956)
at scala.tools.nsc.typechecker.Namers$TypeCompleterBase.complete(Namers.scala:1951)
at scala.tools.nsc.typechecker.Namers$PolyTypeCompleter.completeImpl(Namers.scala:1991)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete(Namers.scala:1958)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete$(Namers.scala:1956)
at scala.tools.nsc.typechecker.Namers$PolyTypeCompleter.complete(Namers.scala:1970)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1530)
at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1678)
at scala.tools.nsc.typechecker.Typers$Typer.checkNotLocked$1(Typers.scala:306)
at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:310)
at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:328)
at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:338)
at scala.tools.nsc.typechecker.Typers$Typer.typedValDefImpl(Typers.scala:2039)
at scala.tools.nsc.typechecker.Typers$Typer.typedValDef(Typers.scala:2024)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5494)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5647)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3086)
at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1987)
at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1811)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5496)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5647)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3086)
at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1987)
at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1811)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5496)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5647)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3086)
at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5207)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5499)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5643)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:104)
at scala.tools.nsc.Global$GlobalPhase.$anonfun$applyPhase$1(Global.scala:436)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:429)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1(Analyzer.scala:94)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1$adapted(Analyzer.scala:93)
at scala.collection.Iterator.foreach(Iterator.scala:929)
at scala.collection.Iterator.foreach$(Iterator.scala:929)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1452)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1436)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1429)
at scala.tools.nsc.Global$Run.compile(Global.scala:1545)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:130)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:105)
at xsbt.CompilerInterface.run(CompilerInterface.scala:31)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:237)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:111)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:90)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:40)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:35)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:83)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:26)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Env:
Scala 2.12.8
JDK 1.8.0_152
POM:
<?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>
<properties>
<scala.version>2.12.8</scala.version>
</properties>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<name>sonatype sapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.12</artifactId>
<version>3.0.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.6</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-Xlint</arg>
<arg>-deprecation</arg>
<arg>-unchecked</arg>
<arg>-feature</arg>
<arg>-language:postfixOps</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:higherKinds</arg>
<arg>-Xfatal-warnings</arg>
<arg>-Ywarn-unused-import</arg>
<arg>-Ywarn-inaccessible</arg>
<arg>-Ywarn-dead-code</arg>
<arg>-Ypartial-unification</arg>
</args>
<compilerPlugins>
<compilerPlugin>
<groupId>org.scala-lang.plugins</groupId>
<artifactId>macro-paradise_${scala.version}</artifactId>
<version>2.1.1</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Thanks for the support.
Try
pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>scala_macros_maven_demo</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<scala.version>2.12.8</scala.version>
<!-- <scala.version>2.13.0</scala.version>-->
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
<modules>
<module>core</module>
<module>macros</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.1.0</version>
<configuration>
<!-- for Scala 2.12.8 -->
<compilerPlugins>
<!-- <compilerPlugin>-->
<!-- <groupId>org.scalamacros</groupId>-->
<!-- <artifactId>paradise_${scala.version}</artifactId>-->
<!-- <version>2.1.1</version>-->
<!-- </compilerPlugin>-->
<compilerPlugin>
<groupId>org.scalameta</groupId>
<artifactId>paradise_${scala.version}</artifactId>
<version>3.0.0-M11</version>
</compilerPlugin>
</compilerPlugins>
<!-- for Scala 2.13.0 -->
<!-- <args>-->
<!-- <arg>-Ymacro-annotations</arg>-->
<!-- </args>-->
</configuration>
</plugin>
</plugins>
</build>
</project>
macros/pom.xml
<?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">
<parent>
<artifactId>scala_macros_maven_demo</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>macros</artifactId>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</project>
core/pom.xml
<?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">
<parent>
<artifactId>scala_macros_maven_demo</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
<dependencies>
<dependency>
<artifactId>macros</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<launchers>
<launcher>
<id>launcher1</id>
<mainClass>com.example.App</mainClass>
</launcher>
</launchers>
</configuration>
</plugin>
</plugins>
</build>
</project>

Having issue with pom.xml

I am trying to integrate Selenium TestNG to maven but having trouble in adding dependencies to pom.xml (as described in this article ), and getting error on the same. Issue appears only when I add selenium and testng dependencies, I have already imported those library to the project. Below is xml code
<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>
<groupId>ProV1</groupId>
<artifactId>ProV1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And this is the error I am getting
As suggested in some articles I cleaned the project, refreshed but nothing worked out.
I am a newbie to Maven so will be very greatfull for all helpful suggestion on how to fix this.
Issue resolved by removing dependencies, there was no need to add dependencies. Maven adds them automatically.

SEVERE: Servlet /JAXRS-HelloWorld threw load() exception java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

I read through plenty of posts related to this issue but couldn't get any help .
ERROR
Appreciate if someone can help me out.
enter image description here
This is how my POM and web looks like . I have tried copying the required war file to C:\appache tomcat 7 but no luck. Even deploying it within the eclipse also gives me the same error.
WEb
enter image description here
POM.xML:-
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworld Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
By the exception, it looks like the com.sun.jersey.spi.container.servlet.ServletContainer class is not available in your classpath.
Note that Jersey 1.x and Jersey 2.x use different package names:
Jersey 1.x: com.sun.jersey
Jersey 2.x: org.glassfish.jersey
So, I understand you are using Jersey 1.x.
Jersey 1.x depencency
To use Jersey 1.x, you need the following dependecy in your pom.xml:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
To read more about Jersey 1.x dependencies, have a look at the documentation.
You can check the latest version of the jersey-server artifactId in the Maven Repository.
Jersey 2.x depencency
If you want to use Jersey 2.x, you have to add the following dependency to your pom.xml:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
You can check the latest version of the jersey-container-servlet artifactId in the Maven Repository.
Read more about Jersey 2.x dependencies in the documentation.
UPDATE
If you can, I do recommend using Jersey 2.x rather than Jersey 1.x.
To do it, use the following pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Hello World</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And the following web.xml:
<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>
If you are trying to make a Web application to provide web service using Jersey library in Tomcat and Eclipse and still getting problem after adding jersey-server.jar in the classpath. You can follow these steps to add dependency on deployment assembly.
Project -> properties -> development assembly -> add -> java build path entries -> maven dependency
This should work.

JFXtras ClassNotFoundException on maven build

I am using Eclipse with the Maven integration and included JFXtras in my project. When I do the maven build, it successfully creates the jar, but when I try to run it, I get a
java.lang.ClassNotFoundException: jfxtras.scene.control.ListSpinner
I integrated jfxtras like described here:
http://mvnrepository.com/artifact/org.jfxtras/jfxtras-labs/8.0-r3
Edit:
<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>
<groupId>propgr</groupId>
<artifactId>Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r1</version>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-controls</artifactId>
<version>8.0-r1</version>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-common</artifactId>
<version>8.0-r1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>main.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Any ideas / help?
JFXtras consist of a number of artifact; labs, controls, common, ..., with some dependencies between them. The dependency for labs is missing. The pom below works for me.
<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>
<groupId>propgr</groupId>
<artifactId>Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r3</version>
</dependency>
</dependencies>
<build>
...
</build>
</project>
That is for a release, if you want to use a snapshot, you need to add the Sonatype snapshot repository in the pom or .m2/settings.xml
<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>
<groupId>propgr</groupId>
<artifactId>Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r4-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oss-sonatype</id>
<name>oss-sonatype</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
...
</build>
</project>

Struts2-Maven in eclipse IDE

I have imported this Struts2-maven project in to my Eclipse.
here is my pom.xml for Struts2
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>manning</groupId>
<artifactId>Form_Tags_Struts2_Mvn</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Form_Tags_Struts2_Mvn</name>
<build>
<finalName>Form_Tags_Struts2_Mvn</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7.0_05</version>
<scope>system</scope>
<systemPath>/usr/lib/jvm/jdk1.7.0_05/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.1.2</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
But when am try to run it shows an exception.
Here is my Exception:
SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:256)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Can any one please help me? actually what happens ?
Try checking your deployment dependency of your project (Properties > Deployment Assembly) and check if Maven Dependencies are included. If you try to add them using Add > Java Build path entries and then select your maven thing.
Hope that helps :)