Exception in thread "main" java.lang.NullPointerException

583 views
Skip to first unread message

Milos Obrknezev

unread,
Dec 19, 2007, 7:10:16 AM12/19/07
to testng...@googlegroups.com
Hi, I'm using TestNG 5.5 and jdk 6.0. I'm geting NullPointerException when I try to run my test class. I'm using testNG eclipse plugin. Here is a stack trace:

Exception in thread "main" java.lang.NullPointerException
at org.testng.xml.TestNGContentHandler.resolveEntity(TestNGContentHandler.java:71)
at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntityAsPerStax(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.testng.xml.Parser.parseOneFile(Parser.java:261)
at org.testng.xml.Parser.parse(Parser.java:158)
at org.testng.TestNG.setTestSuites(TestNG.java:491)
at org.testng.TestNG.configure(TestNG.java:1061)
at org.testng.remote.RemoteTestNG.configure(RemoteTestNG.java:49)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:120)


Does anybody knows what seems to be a problem?

Thanks in advance
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=259218#259218

Alexandru Popescu ☀

unread,
Dec 19, 2007, 7:27:23 AM12/19/07
to testng...@googlegroups.com

I don't have the source of the 5.5 around, but by looking at that code
I cannot imagine how can you get a NPE. Looks very strange. Would it
be possible to upgrade to 5.7 and test if the error still occurs?

./alex
--
.w( the-mindstorm )p.
TestNG co-founder
EclipseTestNG Creator

Milos Obrknezev

unread,
Dec 19, 2007, 7:57:47 AM12/19/07
to testng...@googlegroups.com
I will try that

---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=259240#259240

Milos Obrknezev

unread,
Dec 20, 2007, 4:26:46 AM12/20/07
to testng...@googlegroups.com
I switched to testNG 5.7. I'm geting same exception just on a diferent line. Here is a stack trace:

Exception in thread "main" java.lang.NullPointerException

at org.testng.xml.TestNGContentHandler.resolveEntity(TestNGContentHandler.java:73)


at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntityAsPerStax(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.testng.xml.Parser.parseOneFile(Parser.java:261)
at org.testng.xml.Parser.parse(Parser.java:158)

at org.testng.TestNG.setTestSuites(TestNG.java:472)
at org.testng.TestNG.configure(TestNG.java:882)
at org.testng.remote.RemoteTestNG.configure(RemoteTestNG.java:49)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)

Can you see what is the problem now?

Thanks


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=259967#259967

Alexandru Popescu ☀

unread,
Dec 21, 2007, 3:13:35 PM12/21/07
to testng...@googlegroups.com
That's a totally weird exception, as the corresponding line(s) are:

[code]
if (Parser.DEPRECATED_TESTNG_DTD_URL.equals(publicId)
|| Parser.TESTNG_DTD_URL.equals(publicId)) {
InputStream is =
getClass().getClassLoader().getResourceAsStream(Parser.TESTNG_DTD);
if (null == is) {
[...]
[/code]

I frankly don't have the slightest idea where that NPE is coming from.

./alex
--
.w( the_mindstorm )p.
TestNG co-founder
EclipseTestNG Creator

ldscan

unread,
Jan 10, 2008, 12:26:16 AM1/10/08
to testng...@googlegroups.com
I also got such exception, but when I delete the line -"<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">", anything is normal, why?

---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=274849#274849

Alexandru Popescu ☀

unread,
Jan 10, 2008, 4:08:37 AM1/10/08
to testng...@googlegroups.com
On Jan 10, 2008 7:26 AM, ldscan <testng...@opensymphony.com> wrote:
>
> I also got such exception, but when I delete the line -"<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">", anything is normal, why?

I see... What is your environment? Do you have multiple XML related
jars in your classpath? (I am afraid you've reached one of those XML
hell setups, but I cannot put my finger on it).

Matt Vagnoni

unread,
Jan 10, 2008, 1:08:20 PM1/10/08
to testng...@googlegroups.com
Well, I'll throw this out there...but does your configuration file validate against the testng-1.0.dtd?  Can the dtd file be found? 

In Eclipse it will warn you if it can't find the dtd file (if you open up the xml file).  And you can validate the xml file against the dtd once it is found.

vickey sachdeva

unread,
Feb 3, 2008, 2:55:22 AM2/3/08
to testng...@googlegroups.com
HI Guys,
i just switched from JUnit to TestNG and encountered the same problem as mentioned in thread.
Can some one help me out to find the solution as i cannot proceed further?

Thanks in advance

-Vickey


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=293319#293319

Cédric Beust ♔

unread,
Feb 3, 2008, 11:33:53 AM2/3/08
to testng...@googlegroups.com
Hi everyone,

First of all, I'd encourage you to upgrade to TestNG 5.7.  It might not solve this particular problem, but at least you will get stack traces that we can actually use for debugging.

This error is happening in the XML parsing code, probably when the parser is trying to resolve the DTD.  I can see two possible causes:
  • There is no testng-1.0.dtd file included in the jar file (can you check?).  I would be surprised if this were the case.
  • You have another XML parser in your classpath.  XML parsers are notoriously fickle with this and it's caused problems in the past.  Can you please post your class path so we can take a look?
Also, please try to reproduce the problem in the simplest case possible:  one test class and using the command line.

--
Cédric

vickey sachdeva

unread,
Feb 4, 2008, 3:04:35 AM2/4/08
to testng...@googlegroups.com
i was using eclipse IDE for Java earlier, i think it does not include SDK. Yesterday i un-installed it and installed Eclipse classic with SDK and TestNG started working. The XML problem vanished. i really don't know why.

Just for Information, when i had this XML issue, there were only two libraries in my classpath JRE and TestNg1.5 and i downloaded TestNg Libraries using eclipse plugins update method from the TestNg Update site.

i will try to install Eclipse JAVA IDE again and check if this is a problem with Eclipse or not

-vickey


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=294098#294098

vickey sachdeva

unread,
Feb 4, 2008, 3:05:19 AM2/4/08
to testng...@googlegroups.com
One More thing TestNg version i was using was 5.7 only

-Thanks
Vickey


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=183461&messageID=294108#294108

Reply all
Reply to author
Forward
0 new messages