java.lang.ExceptionInInitializerError while running testng selenium testcase - java

This is my testng class
/**
*
*/
package com.igate.test;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.igate.framework.BaseTestCase;
import com.igate.framework.ExecutionObject;
import com.igate.framework.GalenTestLayout;
import com.igate.framework.Reporter;
import com.igate.framework.WebDriver;
#Test
public class FleetBooking extends BaseTestCase {
public FleetBooking() {
super();
}
public ExecutionObject exeObj;
#BeforeClass
public void createDoc() throws Exception {
Reporter.createDoc(deviceDetail);
exeObj = new ExecutionObject();
}
public void test_case1() throws Exception {
WebDriver oWD = null;
if (runType.contains("mobile")) {
oWD = new WebDriver(ObjMap, caps, deviceDetail);
} else if (runType.contains("desktop")) {
oWD = new WebDriver(ObjMap, caps);
}
try {
oWD.startTestCase("test_casen1", exeObj);
oWD.launchURL("https://fleet.igate.com/fleet/Login.htm");
oWD.wait("MW");
oWD.setPage("LoginPage");
oWD.enterText("username", "831457");
RemoteWebDriver driver = oWD.getDriver();
System.out.println(" returned driver "+driver);
GalenTestLayout layout = new GalenTestLayout();
layout.testLayout(driver, "fleet");
//oWD.layoutTest("fleet");
/*try {
System.out.println("layout under process");
LayoutReport layoutReport = Galen.checkLayout(driver, "gspecs/fleet.gspec",
Arrays.asList("mobile","desktop"));
// Creating a list of tests
List<GalenTestInfo> tests = new LinkedList<GalenTestInfo>();
// Creating an object that will contain the information about the
// test
GalenTestInfo test = GalenTestInfo
.fromString("Login page on mobile device test");
// Adding layout report to the test report
test.getReport().layout(layoutReport,
"check layout on mobile device");
tests.add(test);
System.out.println("report created in reports folder");
// Exporting all test reports to html
new HtmlReportBuilder().build(tests,
"reports");
} catch (IOException e) {
System.out.println("error 1"+e.getMessage());
e.printStackTrace();
}*/
oWD.endTestCase();
} catch (Exception e) {
System.out.println("SYSOUT - exception : " + e);
oWD.endTestCase();
}
}
}
Here is my GalenTestLayout class
package com.igate.framework;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import com.galenframework.api.Galen;
import com.galenframework.reports.GalenTestInfo;
import com.galenframework.reports.HtmlReportBuilder;
import com.galenframework.reports.model.LayoutReport;
import com.galenframework.testng.GalenTestNgTestBase;
public class GalenTestLayout {
public RemoteWebDriver driver;
#Test
public void testLayout(RemoteWebDriver driver,String gspec) {
System.out.println("driver in layout method "+driver);
LayoutReport layoutReport;
try {
System.out.println("layout under process");
layoutReport = Galen.checkLayout(driver, "gspecs/fleet.gspec",
Arrays.asList("mobile","desktop"));
// Creating a list of tests
List<GalenTestInfo> tests = new LinkedList<GalenTestInfo>();
// Creating an object that will contain the information about the
// test
GalenTestInfo test = GalenTestInfo
.fromString("Login page on mobile device test");
// Adding layout report to the test report
test.getReport().layout(layoutReport,
"check layout on mobile device");
tests.add(test);
System.out.println("report created in reports folder");
// Exporting all test reports to html
new HtmlReportBuilder().build(tests,
"reports");
} catch (IOException e) {
System.out.println("error in layout method "+e.getMessage());
e.printStackTrace();
}
}
}
I am getting error in My FleetBooking Class at
**GalenTestLayout layout = new GalenTestLayout();
layout.testLayout(driver, "fleet");**
These are my error logs
[TestNG] Running:
C:\Users\pmadge\AppData\Local\Temp\testng-eclipse-1054887367\testng-customsuite.xml
bin compiled version 1.1
2016-04-26 20:14:08 INFO BaseTestCase:134 - Framework assigned in Internal Path : - Successfull
device size :3
*************taken device*********** 0
increasing count :1
looped i :0
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 20891
Only local connections are allowed.
2016-04-26 20:14:10 INFO WebDriver:739 - StartTestCase - test_casen1 - Successfull
2016-04-26 20:14:10 INFO WebDriver:181 - Launch URL - : https://fleet.igate.com/fleet/Login.htm - Successfull
########$$$$$$$$$$%%%%%%%%%%%%%% ::::::::::::: null
2016-04-26 20:14:15 INFO WebDriver:155 - SetPage - : LoginPage - Successfull
2016-04-26 20:14:17 INFO WebDriver:610 - GetControl - Action Performed : username - Successfull
2016-04-26 20:14:17 INFO WebDriver:622 - FetchControl - Action Performed - Successfull
2016-04-26 20:14:19 INFO WebDriver:612 - GetControl - WebElement - Successfull
2016-04-26 20:14:19 INFO WebDriver:206 - enterText - in: username value: 831457 - Successfull
returned driver ChromeDriver: chrome on XP (92edabdf1bacb26c65c50ac893f7da3f)
driver in layout method ChromeDriver: chrome on XP (92edabdf1bacb26c65c50ac893f7da3f)
layout under process
FAILED: test_case1
java.lang.ExceptionInInitializerError
at com.galenframework.rainbow4j.Rainbow4J.loadImage(Rainbow4J.java:286)
at com.galenframework.utils.GalenUtils.takeScreenshot(GalenUtils.java:314)
at com.galenframework.browser.SeleniumBrowser.makeSimpleScreenshot(SeleniumBrowser.java:97)
at com.galenframework.browser.SeleniumBrowser.createScreenshot(SeleniumBrowser.java:90)
at com.galenframework.page.selenium.SeleniumPage.createScreenshot(SeleniumPage.java:161)
at com.galenframework.api.Galen.checkLayoutForPage(Galen.java:100)
at com.galenframework.api.Galen.checkLayout(Galen.java:86)
at com.galenframework.api.Galen.checkLayout(Galen.java:69)
at com.galenframework.api.Galen.checkLayout(Galen.java:59)
at com.galenframework.api.Galen.checkLayout(Galen.java:154)
at com.galenframework.api.Galen.checkLayout(Galen.java:128)
at com.igate.framework.GalenTestLayout.testLayout(GalenTestLayout.java:31)
at com.igate.test.FleetBooking.test_case1(FleetBooking.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.SecurityException: sealing violation: can't seal package com.sun.media.imageioimpl.plugins.jpeg2000: already loaded
at java.net.URLClassLoader.getAndVerifyPackage(Unknown Source)
at java.net.URLClassLoader.definePackageInternal(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(Unknown Source)
at javax.imageio.spi.IIORegistry.<init>(Unknown Source)
at javax.imageio.spi.IIORegistry.getDefaultInstance(Unknown Source)
at javax.imageio.ImageIO.<clinit>(Unknown Source)
... 37 more
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.jq.Main#1ed3c8d: 21 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#2efe5d: 76 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 4 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#1f95c5d: 36 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#a570f: 4 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#81f4dc: 3 ms
My chrome driver is initialized properly as u can see in my output logs.
When I run the functionality layout.testLayout(driver, "fleet"); as a independent class its running , but when I calling this method from testng class I am getting exception . I tried many alternatives but still it is giving me error

The error is:
Caused by: java.lang.SecurityException: sealing violation: can't seal package com.sun.media.imageioimpl.plugins.jpeg2000: already loaded
at java.net.URLClassLoader.getAndVerifyPackage(Unknown Source)
So that means you try to seal already loaded package. That package is in a file like jai_imageio-*.jar. Check if you have two similar jars and remove one of them.

Related

java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap when executing the test file

My Testcases package has the below code
package Testcases;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import Objectrepository.FBloginpage;
public class Testcase1 {
#Test
public void login() {
System.setProperty("webdriver.chrome.driver", "C:\\Work\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.facebook.com");
FBloginpage fb= new FBloginpage(driver);
fb.Email().sendKeys("sample#gmail.com");
fb.Password().sendKeys("Password");
fb.Login().click();
}
}
My Objectrepository package has the below code in FBloginpage.java
package Objectrepository;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class FBloginpage {
WebDriver driver;
By username = By.id("email");
By password = By.name("pass");
By login = By.xpath("//input[#type='submit']");
public FBloginpage (WebDriver driver) {
this.driver= driver;
}
public WebElement Email() {
return driver.findElement(username);
}
public WebElement Password() {
return driver.findElement(password);
}
public WebElement Login() {
return driver.findElement(login);
}
}
My Testng.xml file has the below code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<classes>
<class name="Testcases.Testcase1"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
When i execute the Testcases1.java file i am getting the below error
[RemoteTestNG] detected TestNG version 6.14.2
FAILED: login
java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:249)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.<init>(ChromeDriverService.java:96)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at Tescases.Testcase1.login(Testcase1.java:14)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableMap
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 30 more
Tried using updated chromedriver but still the problem persist.I am using Eclipse IDE and i imported all the necessary libraries
I too have same issue when I started working. The solution I opted was to first delete all the referenced Selenium files and then download new ones and then assigned them to a folder and added their reference and then it will start working properly.

getting Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function

ok i am using
eclipse neon
Client-combined-3.1.0-nodeps.jar
for firefox-setup 39.0
and this is my code
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class T1 {
public static void main(String[] args){
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.navigate().to("https://www.orbitz.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*[#id='primary-header-hotel']")).click();
String result = driver.getPageSource();
System.out.println("result is "+" "+ result);
driver.close();
}
}
and this is the error
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/common/base/Function at T1.main(T1.java:12) Caused by:
java.lang.ClassNotFoundException: com.google.common.base.Function 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) ... 1 more
i have seen a solution to add path for guava-21.0
but more error
Exception in thread "main" java.lang.IllegalStateException: The path
to the driver executable must be set by the webdriver.gecko.driver
system property; for more information, see
https://github.com/mozilla/geckodriver. The latest version can be
downloaded from https://github.com/mozilla/geckodriver/releases at
com.google.common.base.Preconditions.checkState(Preconditions.java:738)
at
org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:111)
at
org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
at
org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:112)
at
org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:302)
at
org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:312)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:272)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:267)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:263)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:122)
at T1.main(T1.java:12)
after adding line of code and still Client-combined-3.1.0-nodeps.jar
firefox 52.0.1 and using geckodriver-v0.15.0-win64
and still getting the same error
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class T1 {
public static void main(String[] args){
System.setProperty("webdriver.gecko.driver","C:\\Users\\ahmed\\Desktop\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.navigate().to("https://www.orbitz.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*[#id='primary-header-hotel']")).click();
String result = driver.getPageSource();
System.out.println("result is "+" "+ result);
driver.close();
}
}
here is the error
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/common/base/Function at T1.main(T1.java:14) Caused by:
java.lang.ClassNotFoundException: com.google.common.base.Function 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) ... 1 more
In Selenium 3.1.0 you have to do the following to initialize the gecko driver:
System.setproperty("webdriver.gecko.driver","C:\\geckodriver_location\\geckodriver.exe");
Webdriver driver = new Firefoxdriver();
Run your code. It should be success. Let me know if this works for you.

Localization code throwing unexpected exceptions in java

I'm working on a project for school. Part of the prompt for the application specifies that I'm supposed to add localization to the log in page to translate the text in to two other languages. I don't have any experience with localization and Internationalization so I looked up a tutorial on YouTube that you can find here.
The tutorial is slightly simpler than what I'm trying to do, but I thought that I extrapolated the information effectively. What I'm about to post is just a test to see if I could get the log-in prompt text to change language, based on a radio button selection by the user. Here is my log in controller class:
import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class LogInController implements Initializable {
#FXML
private Label logInPrompt;
#FXML
private TextField userNameField;
#FXML
private TextField passwordTextField;
#FXML
private RadioButton english;
#FXML
private RadioButton spanish;
#FXML
private RadioButton french;
#FXML
public void Login(ActionEvent event) throws Exception {
if (userNameField.getText().equals("user") && passwordTextField.getText().equals("password")) {
logInPrompt.setText("Log in successful!");
Stage primaryStage = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("MainMenu.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
} else {
logInPrompt.setText("Log in Failed");
}
}
public String enLang = "en";
public String spLang = "sp";
public String frLang = "fr";
public String unitedStates = "US";
public String mexico = "MX";
public String france = "FR";
Locale us = new Locale(enLang, unitedStates);
ResourceBundle rbEn = ResourceBundle.getBundle("C195/MessageBundle_en_US", us);
Locale mx = new Locale(spLang, mexico);
ResourceBundle rbSp = ResourceBundle.getBundle("C195/MessageBundle_es_MX", mx);
Locale fr = new Locale(frLang, france);
ResourceBundle rbFr = ResourceBundle.getBundle("C195/MessageBundle_fr_FR", fr);
public String enLogIn = rbEn.getString("logInPromptEN");
public String spLogIn = rbSp.getString("logInPromptSP");
public String frLogIn = rbFr.getString("logInPromptFR");
public void langSelect(){
if (english.isSelected()){
logInPrompt.setText(enLogIn);
}else if (spanish.isSelected()){
logInPrompt.setText(spLogIn);
}else if (french.isSelected()){
logInPrompt.setText(frLogIn);
}
}
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
Here is an example of one of my properties files, the other two are the same except they are for the other two languages:
logInPromptSP = Ingrese su nombre de usuario y contraseƱa:
The application runs if I comment out the localization code, but if I run it without the comment I get a list of exceptions and errors a mile long, very few of which I'm familiar with.
To try to figure this problem out, I went back and read through the Localization and Internationalization portion in my OCP study guide, and I searched through StackOverflow using search terms similar to the title of my question.
Any help anyone could offer me on this issue would be greatly appreciated. Also just a quick note: This is the first question I've ever posted on StackOverflow and I read the guidelines but I'm a complete noob at both programming and at using StackOverflow. So please kindly let me know if the way that I formatted my question or the problem I asked about is in any way inappropriate.
Here is the full stack trace:
ant -f C:\\Users\\Forbes\\Documents\\NetBeansProjects\\C195 jfxsa-run
init:
Deleting: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built- jar.properties
deps-jar:
Updating property file: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built-jar.properties
compile:
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Copying 1 file to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Detected JavaFX Ant API version 1.3
jfx-deployment:
jar:
Copying 13 files to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run302791547
jfx-project-run:
Executing C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run302791547\C195.jar using platform C:\Program Files\Java\jdk1.8.0_51\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.j ava:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917 )
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImp l.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1343441044.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/Forbes/Documents/NetBeansProjects/C195/dist/run302791547/C195.jar!/c195/LoginXML.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at c195.C195.start(C195.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherIm pl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$54/1038706898.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java: 326)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/355629945.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$49/722855603.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:29 4)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1915503092.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1963387170.run(Unknown Source)
... 1 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name C195/MessageBundle_en_US, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at c195.LogInController.<init>(LogInController.java:69)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI mpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA ccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.ja va:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
... 22 more
Exception running application c195.C195
Java Result: -1073741819
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run302791547
jfxsa-run:
BUILD SUCCESSFUL (total time: 5 seconds)
Here is the updated stack trace after following your advice.
ant -f C:\\Users\\Forbes\\Documents\\NetBeansProjects\\C195 jfxsa-run
init:
Deleting: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built- jar.properties
deps-jar:
Updating property file: C:\Users\Forbes\Documents\NetBeansProjects\C195\build\built-jar.properties
compile:
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Copying 1 file to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\lib
Detected JavaFX Ant API version 1.3
jfx-deployment:
jar:
Copying 13 files to C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run1318536498
jfx-project-run:
Executing C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run1318536498\C195.jar using platform C:\Program Files\Java\jdk1.8.0_51\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.j ava:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917 )
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImp l.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1343441044.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/Forbes/Documents/NetBeansProjects/C195/dist/run1318536498/C195.ja r!/c195/LoginXML.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at c195.C195.start(C195.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherIm pl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$54/1361720784.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java: 326)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/355629945.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$49/722855603.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:29 4)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1915503092.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1963387170.run(Unknown Source)
... 1 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name MessageBundle_en_US, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at c195.LogInController.<init>(LogInController.java:70)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI mpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA ccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.ja va:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
... 22 more
Exception running application c195.C195
Java Result: -1073741819
Deleting directory C:\Users\Forbes\Documents\NetBeansProjects\C195\dist\run1318536498
jfxsa-run:
BUILD SUCCESSFUL (total time: 5 seconds)

Getting ClassNotFoundException while using Class.forName("com.actitime5.Testcases."+vriable);

I've been messing around with ClassLoaders in java recently, trying to run my automation script code which uses dynamic loading of classes and geting ClassNotFoundException.
##MyCode
package com.actitime5.frameworkengine;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import com.gmail5.Testcases.LoginLogout;
import org.junit.runner.JUnitCore;
public class Init {
public static void main(String args[]) throws Exception
{
Init in=new Init();
String url=in.getConfigValue("url");
ExcelLibrary lib=new ExcelLibrary();
JUnitCore core = new JUnitCore();
int numberofTestcases=lib.getRowCont("Scenario");
System.out.println(numberofTestcases);
for(int i=1;i<=numberofTestcases;i++)
{String status=lib.getExcelData("Scenario", i, 1);
if(status.equals("yes"))
{String scriptnam=lib.getExcelData("Scenario", i, 0);
System.out.println("Sheet Name"+" "+scriptnam);
Class scriptToRun= Class.forName("com.gmail5.Testcases."+scriptnam);
core.run(scriptToRun);
}
}}
##Errors that i am getting :
1
Sheet Name LoginLogout
Exception in thread "main" java.lang.ClassNotFoundException:com.gmail5.Testcases.LoginLogout
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.gmail5.frameworkengine.Init.main(Init.java:24)
The class which I am trying to load is available in package: com.gmail5.Testcases.*;,but still it throws exception
I think your class name has trailing whitespace. Try trim()ming it off before attempting to load the class.
You can confirm this by replacing
System.out.println("Sheet Name"+" "+scriptnam);
with
System.out.println("Sheet Name"+" '"+scriptnam+"'");
I expect this will print out something like the following:
Sheet Name 'LoginLogout '
When I clicked 'edit' to edit your question, I could see there was trailing whitespace after the class name in the stack trace and in your Sheet Name message. (I didn't change anything in your question: I just used the Edit function to see the raw text of your question, and then clicked Cancel.)

Problem while running j2me application in netbeans

i am very new to j2me. i have created a sample program, but i am not able run that program. Build failed message came. My code is :
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* #author aneesh
*/
public class httpconnection extends MIDlet {
private Command exit, start;
private Display display;
private Form form;
public httpconnection ()
{
}
public void startApp() {
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
start = new Command("Start", Command.EXIT, 1);
form = new Form("Http Connection");
form.addCommand(exit);
form.addCommand(start);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
and the error i am getting is
java.lang.UnsatisfiedLinkError: /usr/local/netbeans-7.0/mobility/WTK2.5.2/bin/sublime.so: /usr/local/netbeans-7.0/mobility/WTK2.5.2/bin/sublime.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1646)
at java.lang.Runtime.load0(Runtime.java:787)
at java.lang.System.load(System.java:1022)
at com.sun.kvem.Sublime.<init>(Unknown Source)
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:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at com.sun.kvem.Lime.createLime(Unknown Source)
at com.sun.kvem.KVMBridge.<init>(Unknown Source)
at com.sun.kvem.KVMBridge.getBridge(Unknown Source)
at com.sun.kvem.midp.MIDP.run(Unknown Source)
at com.sun.kvem.environment.EmulatorInvoker.runEmulatorImpl(Unknown Source)
at com.sun.kvem.environment.EmulatorInvoker.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.sun.kvem.environment.JVM.main(Unknown Source)
NetBeansProjects/VDCustomComponents1/nbproject/build-impl.xml:915: Execution failed with error code 1.
BUILD FAILED (total time: 3 seconds)
It seems like you have 32-bit WTK and 64-bit JDK. You should install the matching 32-bit JDK and set the WTK to use it.
Command-line WTK installer downloaded from Sun (Oracle) website should ask you for the JDK location during installation.

Categories