[TestNG] [ERROR] An error occurred while instantiating class wpp.Sanity: null

7,748 views
Skip to first unread message

avontz

unread,
Nov 28, 2011, 1:41:41 PM11/28/11
to testng-users
Hi there people.

I got a error today that its kind of strange.

On my workstation (win xp), i do compile my test on commando line and
they run like a charm but when i do the same setup on a Windows2008
server, it throws that error:

"[TestNG] [ERROR]
An error occurred while instantiating class wpp.Sanity: null"

The app compile it without any error and my classpath is ok.

I tried with Java 6 (last update) and Java 7 (last update) and the
result is the same..

Works fine on XP... Same error on Windows 2008 Server.

I also tried with different testng version (testng-6.0.1 and
testng-6.3.1)

I googled the error but it didnt helped at all....

Hope someone passed throught it and knows a answer :)

Thks for you time.

Att,
Leonardo

Cédric Beust ♔

unread,
Nov 28, 2011, 1:47:27 PM11/28/11
to testng...@googlegroups.com
Any stack trace?

-- 
Cédric





--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


Krishnan Mahadevan

unread,
Nov 28, 2011, 1:50:42 PM11/28/11
to testng...@googlegroups.com
http://code.google.com/p/testng/source/browse/trunk/src/main/org/testng/internal/ClassHelper.java?r=620#342
That is what seems to be throwing the error that you mentioned.

It would be good if you could please share the code that is causing this error along with the stacktrace as Cedric requested

since the comment before the exception says 

// Something else went wrong when running the constructor

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



2011/11/29 Cédric Beust ♔ <ced...@beust.com>

Leonardo Galani

unread,
Nov 28, 2011, 2:09:12 PM11/28/11
to testng...@googlegroups.com
No stacktrace Cedric...

I tried to run it with -verbose :


[Loaded com.google.common.collect.Maps$TransformedEntriesMap from file:/C:/Autom
ation/NonoDigito/Lib/guava-10.0.1.jar]

[TestNG] [ERROR]
An error occurred while instantiating class wpp.Sanity: null
[Loaded java.util.IdentityHashMap$KeySet from C:\Program Files\Java\jdk1.6.0_27\
jre\lib\rt.jar]
[Loaded java.util.IdentityHashMap$IdentityHashMapIterator from C:\Program Files\
Java\jdk1.6.0_27\jre\lib\rt.jar]
[Loaded java.util.IdentityHashMap$KeyIterator from C:\Program Files\Java\jdk1.6.
0_27\jre\lib\rt.jar]
[Loaded java.util.concurrent.CopyOnWriteArrayList$COWIterator from C:\Program Fi
les\Java\jdk1.6.0_27\jre\lib\rt.jar]



The code is no big deal.. as it runs OK on Windows XP.. with eclipse or command line..

but anyway.. here is the code:

package wpp;

import org.testng.annotations.Test;
import core.Setup;

public class Sanity extends Setup {
   
    @Test
    public void sanityTest()
    {
        url = "http://xx.xxxx.xxx:8902/wpp/";
        driver.get(url);
        common.WPP.Login();       
    }
}




i did a ".bat" to compile and run it by command line:


"


set javaTestProjectPath=C:\workspace\Project
c:
cd %javaTestProjectPath%

set path=C:\Program Files\Java\jdk1.7.0_01\bin

set classpath=%javaTestProjectPath%\bin;%javaTestProjectPath%\bin\wpp;%javaTestProjectPath%\core;%javaTestProjectPath%\teste;%javaTestProjectPath%\teste\wpp; +++libs

javac  -verbose %javaTestProjectPath%\teste\wpp\Sanity.java -d %javaTestProjectPath%\bin\

java -verbose org.testng.TestNG %javaTestProjectPath%\bin\testng.xml






Att
Leonardo Barba Galani
Tester!

Java, Selenium e Coca Cola

Cédric Beust ♔

unread,
Nov 28, 2011, 2:28:05 PM11/28/11
to testng...@googlegroups.com
TestNG seems to be having a problem instantiating this class, maybe there is something wrong in the SetUp class? What if you make this class not extend any class?

-- 
Cédric

Leonardo Galani

unread,
Nov 28, 2011, 2:42:53 PM11/28/11
to testng...@googlegroups.com
Here is the "setup" class


package core;

import org.openqa.selenium.*;
import org.openqa.selenium.ie.*;
import org.testng.annotations.*;

public class Setup {

public String url;   
public static WebDriver driver = new InternetExplorerDriver();
               
        @BeforeMethod
        public void startSelenium() {
           
        }

        @AfterMethod
        public void stopSelenium() {
            driver.close();
        }
}



Here is the common.wpp class

package common;

import org.openqa.selenium.By;
import core.Setup;

public class WPP extends Setup{

    public static void Login()
    {
        driver.findElement(By.name("j_username")).sendKeys("999999999");
        driver.findElement(By.name("j_password")).sendKeys("999999999");
        driver.findElement(By.xpath("//tr[5]/td/input")).click();
    }
   
}



The thing is..... why my code works fine on windows xp and not on windows 2008? it doesnt make any sense.....
I did what you said..  everything on the same class.. same error.

Leonardo Galani

unread,
Nov 28, 2011, 2:53:18 PM11/28/11
to testng...@googlegroups.com
I tooked all the stuff out.. it compile and run ok...

Guess there is lib that selenium uses and its messing with my tests...

Thks for the help. .sorry for wasting your time.

Leonardo Galani

unread,
Nov 28, 2011, 3:15:28 PM11/28/11
to testng...@googlegroups.com
Only to let you guys now..

The problem is calling with Internet Explorer driver from webdriver...

No im wondering how i will do a workaround...
Reply all
Reply to author
Forward
0 new messages