Discussion:
[testng-users] TestNGException while executing mavenized selenium project from Command prompt
Rishi Khanna
2014-10-28 02:59:59 UTC
Permalink
I am running mavenized TestNG Webdriver project from command prompt using '*mvn
clean install*' but I get the following exception in the cmd prompt

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
17:test (default-test) on project WebdriverWithTestNG: Execution default-test of
goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was
an error in the forked process
[ERROR] org.testng.TestNGException:
[ERROR] An error occurred while instantiating class com.generic.validateorders.W
ebAppTest: null
[ERROR] at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:398)

On the other hand whenever I run it from the eclipse it executes perfectly
fine without any issues. Is there any issue with my project classpath? If
yes then how do I fix it. I have attached the complete stack trace of the
exception.
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Krishnan Mahadevan
2014-10-28 04:47:18 UTC
Permalink
I would start looking from here :

[ERROR] Caused by: java.lang.RuntimeException: Exception in static method
of Logger Class. [ERROR] at
com.generic.utilities.Logg.<clinit>(Logg.java:40) [ERROR] ... 29 more
[ERROR] Caused by: java.io.IOException: The system cannot find the path
specified [ERROR] at java.io.WinNTFileSystem.createFileExclusively(Native
Method) [ERROR] at java.io.File.createNewFile(File.java:947) [ERROR] at
com.generic.utilities.Logg.<clinit>(Logg.java:29) [ERROR] ... 29 more
[ERROR] -> [Help 1]

your com.generic.utilities.Logg initializer (either a constructor a static
block) is facing some issues with some path.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"
Post by Rishi Khanna
I am running mavenized TestNG Webdriver project from command prompt using '*mvn
clean install*' but I get the following exception in the cmd prompt
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
17:test (default-test) on project WebdriverWithTestNG: Execution default-test of
goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was
an error in the forked process
[ERROR] An error occurred while instantiating class com.generic.validateorders.W
ebAppTest: null
[ERROR] at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:398)
On the other hand whenever I run it from the eclipse it executes perfectly
fine without any issues. Is there any issue with my project classpath? If
yes then how do I fix it. I have attached the complete stack trace of the
exception.
--
You received this message because you are subscribed to the Google Groups
"testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Rishi Khanna
2014-10-28 06:33:11 UTC
Permalink
hey Krishnan, my concern is that everything work perfectly when running
through eclipse but as soon as I execute the project from cmd prompt it
throws exception. I want to run it from the cmd prompt so that I can use CI
tool to execute it.
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Krishnan Mahadevan
2014-10-28 06:46:11 UTC
Permalink
Please remember that when you run from within eclipse, I dont think Maven
is involved. The TestNG plugin relies on using the embedded TestNG jar to
run your tests, which isnt the case when you trigger a mvn clean install.

So have you tried finding out what is going on in the section that I
highlighted ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"
Post by Rishi Khanna
hey Krishnan, my concern is that everything work perfectly when running
through eclipse but as soon as I execute the project from cmd prompt it
throws exception. I want to run it from the cmd prompt so that I can use CI
tool to execute it.
--
You received this message because you are subscribed to the Google Groups
"testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Rishi Khanna
2014-10-28 07:30:47 UTC
Permalink
I am trying to create a file using file.createNewFile() and this function
java.io.IOException: The system cannot find the path specified *
The system is not able to find the path: *logs/" + FileName *when I run it
from the cmd prompt. The logs folder exists in my project, do I need to
make it a source folder?

static {
/**
* This is the static block which appends the log file name with the
* timestamp to make it unique
*/
try {
String dateTime =
DateAndTime.getFormattedCurrentDateAndTime(DATEANDTIMEFORMAT);
String FileName = FILENAME + "-" + dateTime + ".log";
File file = new File("logs/" + FileName);
if (file.createNewFile()) {
Properties props = new Properties();
props.load(new FileInputStream(LOGPROPERTTFILEPATH));
props.setProperty("log4j.appender.File.File", "logs/" +
FileName);
LogManager.resetConfiguration();
PropertyConfigurator.configure(props);
System.out.println("Property log4j.appender.File.File =
logs/" + FileName);
} else {
System.out.println("File aready exists");
}
} catch (Exception ex) {
throw new RuntimeException("Exception in static method of
Logger Class. ", ex);
}

}
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Krishnan Mahadevan
2014-10-28 07:35:57 UTC
Permalink
Since I dont have an insight into what your project is doing with this
folder, I dont think I would be able to help beyond this.

One thing you can do is try the following :

new File("logs/").mkdirs();

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"
I am trying to create a file using file.createNewFile() and this function
java.io.IOException: The system cannot find the path specified *
The system is not able to find the path: *logs/" + FileName *when I run
it from the cmd prompt. The logs folder exists in my project, do I need to
make it a source folder?
static {
/**
* This is the static block which appends the log file name with the
* timestamp to make it unique
*/
try {
String dateTime =
DateAndTime.getFormattedCurrentDateAndTime(DATEANDTIMEFORMAT);
String FileName = FILENAME + "-" + dateTime + ".log";
File file = new File("logs/" + FileName);
if (file.createNewFile()) {
Properties props = new Properties();
props.load(new FileInputStream(LOGPROPERTTFILEPATH));
props.setProperty("log4j.appender.File.File", "logs/" +
FileName);
LogManager.resetConfiguration();
PropertyConfigurator.configure(props);
System.out.println("Property log4j.appender.File.File =
logs/" + FileName);
} else {
System.out.println("File aready exists");
}
} catch (Exception ex) {
throw new RuntimeException("Exception in static method of
Logger Class. ", ex);
}
}
--
You received this message because you are subscribed to the Google Groups
"testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Rishi Khanna
2014-10-28 10:37:27 UTC
Permalink
Thanks Krishnan.. I will try to figure out what the issue
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
SUBRAMANYESWARA RAO BHAVIRISETTY
2014-10-28 14:37:21 UTC
Permalink
Hi RIshi,

Just curious why you are trying to create log files. I guess you can use
log4j which would create log files and has lot of advantages.

log4j.rootLogger=INFO
log4j.logger.com.yahoo=DEBUG,file
log4j.logger.httpclient.wire=OFF

log4j.appender.screen=org.apache.log4j.ConsoleAppender
log4j.appender.screen.Threshold=DEBUG
log4j.appender.screen.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.ss}
%-5p (%F:%L) [%t]: %m%n

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.Threshold=DEBUG
log4j.appender.file.File=logs/${groups}.debug.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=20
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.ss}
%-5p (%F:%L) [%t]: %m%n

This will create all the log files in logs directory which is created by
log4j itself.
Post by Rishi Khanna
Thanks Krishnan.. I will try to figure out what the issue
--
You received this message because you are subscribed to the Google Groups
"testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--
Subramanyam
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Rishi Khanna
2014-10-28 16:41:13 UTC
Permalink
Hey SUBRAMANYESWARA ,
I already have the log4j code in my project and it runs perfectly fine from
the eclipse but the mavenized project throws exception when I execute it
from the cmd prompt using
mvn clean install

My log4j code creates all the log files inside a *log* folder, which is
created manually. The problem is that the log folder is not visible to the
command prompt and it throws exception but from the eclipse there is no
such issue
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...