• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Maven and TESTNG

 
Ranch Hand
Posts: 459
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a project in Eclipse and a class who run a TESTNG suite programmatically:



one very simple test class in the src directory




and a pon xml who containd a dependency to TestNG.

IF I run the App class the output is correct, but if I ran
java -cp target/axway-0.0.1-SNAPSHOT.jar anda.firsttestNG.axway.App
from cmd with Maven I got:

Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/xml/XmlSuite
       at anda.firsttestNG.axway.App.main(App.java:18)
Caused by: java.lang.ClassNotFoundException: org.testng.xml.XmlSuite
       at java.net.URLClassLoader.findClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)

Why maven can't find the path to TestNG jar file?

Thanks in advance




 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This suggests you are running the command from the command line. So while it was built with Maven, you are still running it yourself. Which makes sense.


That means you need to add testng (and anything else the app depends on) to your classpath. Alternatively, you can create a shaded jar in Maven that has everything you need in it.
 
Dana Ucaed
Ranch Hand
Posts: 459
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can create a shaded jar in Maven?
 
Dana Ucaed
Ranch Hand
Posts: 459
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your info was very helpful for me.

I solved.

 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic