This question already has answers here:
java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap error using GeckoDriver Firefox through Selenium in Java
(1 answer)
Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError
(7 answers)
Closed 2 years ago.
Hi i'm rather new to selenium and understand the basics but cant understand why my basic code it just open a web page is throwing the error its throwing. The error its throwing ill be listed at the bottom.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Selenium1 {
public static void main(String[] args) {
WebDriver Driver = new ChromeDriver ();
String web = "https://www.facebook.com/";
Driver.get(web);
System.out.println(Driver.getTitle());
}
}
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/common/collect/ImmutableMap at
org.openqa.selenium.remote.service.DriverService$Builder.(DriverService.java:259)
at
org.openqa.selenium.chrome.ChromeDriverService$Builder.(ChromeDriverService.java:101)
at
org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
at Selenium1.main(Selenium1.java:10) Caused by:
java.lang.ClassNotFoundException:
com.google.common.collect.ImmutableMap at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Related
Hello First time posting so sorry if this is bad
I keep running into this error code, I have tried reinstalling different versions of JDA and the only one that works is JDA-4.3.0_333, I am using eclipse. I even reinstalled eclipse to the for developers version. I have restarded and rewritten multiple times runnning into the same error
Exception in thread "main" java.lang.NoClassDefFoundError: net/dv8tion/jda/api/JDABuilder
at threeStringsMusicBot.StartUp.main(StartUp.java:11)
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.JDABuilder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
package threeStringsMusicBot;
import javax.security.auth.login.LoginException;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
public class StartUp {
public static void main(String[] args) throws LoginException{ //Login Exception allows for bot to log into bot account'
JDABuilder threeStrings = JDABuilder.createDefault("#######"); //create new bot with JDABuilder class and give it our bot token
threeStrings.setActivity(Activity.playing("The Lute!")); //set bot activity
threeStrings.setStatus(OnlineStatus.ONLINE); //set bit status to online
threeStrings.build(); //build(); function calls for bot to login
}
}
needed to be on JAVA 1.8, I was previously on the current version of java but this version of JDA needed java 1.8.
This question already has answers here:
Replacements for deprecated JPMS modules with Java EE APIs
(11 answers)
Closed 4 years ago.
I keep getting the NoClassDefFoundError error. I am trying to send an email using the JavaMail API, but the error occurs when I'm creating an instance of Message using the SMTPMessage class.
I know I need the activation library, but it still doesn't work.
By the way, I'm using JDK 10.
The error happens on the first line of this code.
#Override
public void sendEmail(Mail mail) throws MessagingException
{
Message message = new SMTPMessage(this.session);
message.setSubject(mail.getHeader());
message.setFrom(mail.getFrom());
message.setSentDate(mail.getDateClone());
if (mail.getSignature() != null)
message.setText(mail.getText() + "\n\n" + mail.getSignature());
else
message.setText(mail.getText());
Transport.send(message);
}
Stacktrace
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
at martin.mail.EmailHandler.sendEmail(EmailHandler.java:79)
at martin.Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 2 more
Solution
Just add the activation library to your own class path. You can put it in your own package.
I'm trying to run selenium webdriver program, getting following error :
Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.io.FileHandler.unzip(Ljava/io/InputStream;)Ljava/io/File;
Firefox version : 47.0.1
Selenium version : 2.53.1
Eclipse : Oxygen Release (4.7.0)
import org.apache.xpath.XPathContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class PG1
{
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("http://demo.guru99.com/selenium/newtours/");
System.out.println("The title of page is : " + driver.getTitle());
driver.close();
}
}
This program was working fine in another laptop, but not working on new laptop/setup.
Can someone please help.
Error I'm getting :
Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.io.FileHandler.unzip(Ljava/io/InputStream;)Ljava/io/File;
at org.openqa.selenium.firefox.internal.FileExtension.obtainRootDirectory(FileExtension.java:82)
at org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:59)
at org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:64)
at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:443)
at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:421)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:85)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.startClient(RemoteWebDriver.java:303)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:125)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at bitbfw.PG1.main(PG1.java:11)
Found what was wrong..
it was that in "Java Build Path", the JRE system library was not added earlier. I went to configure Build path-->Add Jars selected "jRE system library", Applied & Closed.
Then on all the programs worked fine.
This question already has answers here:
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
(2 answers)
How to fix ClassNotFoundException: org.apache.commons.logging.LogFactory?
(5 answers)
Closed 6 years ago.
I am trying to send a notification using this class FCMHelper and im getting errors
errors leading me to an error in httpclient
this is my code ...
public void send() throws IOException{
JsonObject notificationObject = new JsonObject();
notificationObject.addProperty("data", "hello");
notificationObject.addProperty("to", "dSvX_cWo5iY:A......QQT-bkb8x0VO");
FireBase firebase = FireBase.getInstance();
firebase.sendNotification("to", "condition", notificationObject);
}
i got this error
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1783)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
... 58 more
what the problem here or if someone could give any other way to do it
.. thanks for your help
It seems "org/apache/commons/logging/LogFactory" is missed.
Have you imported the library?
This question already has answers here:
Official reasons for "Software caused connection abort: socket write error"
(14 answers)
Closed 7 years ago.
My settings :
TestNG 6.9.10 - Java 1.8 - Eclipse Mars.1 Release (4.5.1)
Windows 10
Every time I run a TestNG test suite I have this error :
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
at java.io.ObjectOutputStream.<init>(Unknown Source)
at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:24)
at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:43)
at org.testng.remote.RemoteTestNG$RemoteSuiteListener.onStart(RemoteTestNG.java:257)
at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:208)
at org.testng.SuiteRunner.run(SuiteRunner.java:266)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)
Even if my test class is empty :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class sample {
public WebDriver driver;
#Test
public void f() {
}
#BeforeTest
public void beforeTest() {
driver = new FirefoxDriver();
driver.get("http://localhost:8081/login.html?profile=desktop");
}
#AfterTest
public void afterTest() {
driver.close();
}
}
The test is running, so it doesn't interfere with the test case, but I really would like to understand and remove this Exception.
Thank you for any idea.
I'm thinking somewhere in WebDriver, java.net is used. Your localhost webserver is closing the socket or it was closed prematurely. Instead of using Before and After test, try to write it all in one Test method and debug. Unfortunately, there's no mention of your class in the stack trace to pinpoint which call is causing the problem.
Step through the following and see where the exception is thrown. If it's on the driver.get call, then your http server is likely rejecting the connections. If it's thrown at the close(), the connection has already been dropped (probably rejected by the server).
#Test
public void test() {
driver = new FirefoxDriver();
driver.get("http://localhost:8081/login.html?profile=desktop");
driver.close();
}