Hi,
I think every one needs to debug,but I can't find a sample.I don't use any IDE,just edit my build.xml for ant.I hava a project named ExemptionTest.
I have tried to debug ExemptionTest project using jdb command,but
failed.
root@reportingdev3:~/Exemption/trunk/ExemptionTest# jdb -sourcepath
./src freebird.ExemptionWebServiceTest
Initializing jdb ...>
stop at freebird.ExemptionWebServiceTest:48
Deferring breakpoint freebird.ExemptionWebServiceTest:48.It
will be set after the class is loaded.
> runrun freebird.ExemptionWebServiceTestSet
uncaught java.lang.Throwable
Set deferred uncaught
java.lang.Throwable> VM Started:
Exception occurred: java.lang.ClassNotFoundException
(uncaught)"thread=main", java.net.URLClassLoader$1.run(), line=202
bci=73
main[1] Maybe
it needs to launch JVM first and attach jdb later.But it's very hard to
find a simple sample to explain how to do it.I created a TestNG project
using NetBeans,and looked into its ant script files.
It seems that the ant debug task should look like so:
<target name="debug-testng">
<delete dir="${test-output}" quiet="true"/>
<mkdir
dir="${test-output}"/> <java
classname="org.testng.TestNG" dir="${basedir}" fork="true">
<jvmarg
line="-Xdebug"/> <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=9999"/>
<jvmarg line="
"/> <arg line="-d test_output"/>
<arg
line="-sourcedir ${src}"/> <arg
line="suite.xml"/>
<syspropertyset> <propertyref
prefix="test-sys-prop."/>
<mapper
from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<jvmarg
value="-Dtestng.test.classpath=build/classes"/>
<classpath>
<path
path="lib"/> </classpath>
<jvmarg
value="-ea"/> <syspropertyset>
<propertyref
prefix="run-sys-prop."/> <mapper
from="run-sys-prop.*" to="*" type="glob"/>
</syspropertyset> </java>
</target>I
also created a suit.xml file for this.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Custom suite"
parallel="none"> <test verbose="3"
name="ExemptionTest">
<classes>
<class name="freebird.ExemptionWebServiceTest"/>
</classes>
</test></suite>
The above ant task may be converted into the following commands:
java -Xdebug
-Xrunjdwp:transport=dt_socket,address=9999
-Dtestng.test.classpath=build/classes -ea -classpath
./build/classes:./lib/log4j-1.2.15.jar:./lib/testng-5.12.1.jar:./build/classes
org.testng.TestNG suite.xml
But I got this message:
ERROR: transport error 202: connect failed: Connection refusedERROR:
JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error
AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized
[../../../src/share/back/debugInit.c:690]FATAL ERROR in
native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Aborted I get
stuck now.Could you help me or give me your ant scripts?
陈抒
Best regards
http://blog.csdn.net/sheismylife