error writing to output directory

166 views
Skip to first unread message

Raymond Camden

unread,
Jan 12, 2011, 12:45:19 PM1/12/11
to mxunit
I'm seeing this in my console:

[mxunittask] [mxunit error] Error trying to write to : testresults.
Please make sure this output dircetory exists.

But what I don't get is why. I've defined the following:

<property name="output.dir" value="c:\testresults" />

and then here is my mxunit tags...

<target name="runUnitTests" >
<mkdir dir="${output.dir}" />
<echo message="Creating ${output.dir}" />
<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask"
classpath="mxunit-ant.jar" />
<mxunittask server="the server..." port="80" defaultrunner="$
{test.runner}" outputdir="${output.dir}" verbose="true">
<directory path="${test.dir.location}" recurse="true"
componentPath="stuff.unittests" />
</mxunittask>
</target>

When run I clearly see my output directory being created. I also tried
modifying <echo> to write to a file within the directory. That worked
too. But mxunit seems unable to write to the folder.

bill shelton

unread,
Jan 12, 2011, 1:20:52 PM1/12/11
to mxunit
Ray,

Could you run your Ant script with -v (-verbose) option and post the
stacktrace?

thx,
bill

Raymond Camden

unread,
Jan 12, 2011, 1:27:06 PM1/12/11
to mxu...@googlegroups.com
Sure - but I'm removing a bit for privacy sake. Note - there is an error _after_ the dir error about site certificates. I'm not so worried about that yet. But if _that_ error is the root cause and the first error is just a side effect, then let me know.

Apache Ant version 1.8.1 compiled on April 30 2010
Trying the default build file: build.xml
Buildfile: C:\.hudson\jobs\REX (AKA Trunk)\workspace\trunk\documentation\build.xml
Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_21\jre
Detected OS: Windows Server 2008
parsing buildfile C:\.hudson\jobs\REX (AKA Trunk)\workspace\trunk\documentation\build.xml with URI = file:/C:/.hudson/jobs/REX%20(AKA%20Trunk)/workspa
ce/trunk/documentation/build.xml
Project base dir set to: C:\.hudson\jobs\REX (AKA Trunk)\workspace\trunk\documentation
parsing buildfile jar:file:/C:/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/apache-ant-1.8.1/lib/ant.jar!/org
/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `runUnitTests' is [runUnitTests]
Complete build sequence is [runUnitTests, deletia, ]

runUnitTests:
    [mkdir] Skipping c:\testresults because it already exists.
[mxunittask] no_auth
[mxunittask] [HttpHelper] NO authentication
[mxunittask] Greetings, earth being ...
[mxunittask] Running MXUnitAntTask version : 1.0.5
[mxunittask] Outputting results to: c:\testresults
[mxunittask] Verbose: true
[mxunittask] MXunit home :mxunit
[mxunittask] Using server:port : deletia:80
[mxunittask] Using connectionMethod: http
[mxunittask] AuthMethod: no_auth
[mxunittask] Default runner : /unitTests/automation/HttpAntRunner.cfc
[mxunittask] [HttpHelper] Running URL : http://deletia:80/unitTests/automation/HttpAntRunner.cfc?method=run&type=dir&value=D:%5CMav
erick%5CApplication%5CunitTests&recurse=true&excludes=null&packageName=mxunit.testresults&componentPath=deletia.unittests
[mxunittask] Running http ....
[mxunittask] [mxunit error] Error trying to write to : c:\testresults. Please make sure this output dircetory exists.
[mxunittask] [mxunit error] Exiting ... see stacktrace for details.
[mxunittask] javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath
.SunCertPathBuilderException: unable to find valid certification path to requested target
[mxunittask]    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
[mxunittask]    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1623)
[mxunittask]    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:198)
[mxunittask]    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:192)
[mxunittask]    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1074)
[mxunittask]    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:128)
[mxunittask]    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:529)
[mxunittask]    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:465)
[mxunittask]    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
[mxunittask]    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1120)
[mxunittask]    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
[mxunittask]    at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
[mxunittask]    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
[mxunittask]    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
[mxunittask]    at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
[mxunittask]    at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
[mxunittask]    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
[mxunittask]    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
[mxunittask]    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
[mxunittask]    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
[mxunittask]    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
[mxunittask]    at org.mxunit.ant.HttpHelper.runTest(HttpHelper.java:203)
[mxunittask]    at org.mxunit.ant.MXUnitAntTask.doTest(MXUnitAntTask.java:317)
[mxunittask]    at org.mxunit.ant.MXUnitAntTask.runDirectoryTests(MXUnitAntTask.java:307)
[mxunittask]    at org.mxunit.ant.MXUnitAntTask.execute(MXUnitAntTask.java:222)
[mxunittask]    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[mxunittask]    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[mxunittask]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[mxunittask]    at java.lang.reflect.Method.invoke(Method.java:597)
[mxunittask]    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[mxunittask]    at org.apache.tools.ant.Task.perform(Task.java:348)
[mxunittask]    at org.apache.tools.ant.Target.execute(Target.java:390)
[mxunittask]    at org.apache.tools.ant.Target.performTasks(Target.java:411)
[mxunittask]    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
[mxunittask]    at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
[mxunittask]    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[mxunittask]    at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
[mxunittask]    at org.apache.tools.ant.Main.runBuild(Main.java:801)
[mxunittask]    at org.apache.tools.ant.Main.startAnt(Main.java:218)
[mxunittask]    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[mxunittask]    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[mxunittask] Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcepti
on: unable to find valid certification path to requested target
[mxunittask]    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:325)
[mxunittask]    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:219)
[mxunittask]    at sun.security.validator.Validator.validate(Validator.java:218)
[mxunittask]    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
[mxunittask]    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
[mxunittask]    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
[mxunittask]    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1053)
[mxunittask]    ... 36 more
[mxunittask] Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[mxunittask]    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
[mxunittask]    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
[mxunittask]    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:320)
[mxunittask]    ... 42 more

bill shelton

unread,
Jan 12, 2011, 2:08:43 PM1/12/11
to mxunit
Ray,

It looks like the cert error may be the root cause. You should be
seeing an http status code immediately following "[mxunittask] Running
http ...."; e.g., 200, 500, etc. But an IOException is being caught
instead at that point. The task is trying to read data from the http
inputstream, which doesn't exist, perhaps, because the http client is
not ignoring the cert. Can you fix the cert or somehow bypass it?
(I'll also look to see how we might be able to ignore that with
HttpClient)

bill
> [mxunittask] [HttpHelper] Running URL :http://deletia:80/unitTests/automation/HttpAntRunner.cfc?method=run&t...
> erick%5CApplication%5CunitTests&recurse=true&excludes=null&packageName=mxun­it.testresults&componentPath=deletia.unittests
> [mxunittask] Running http ....
> [mxunittask] [mxunit error] Error trying to write to : c:\testresults.
> Please make sure this output dircetory exists.
> [mxunittask] [mxunit error] Exiting ... see stacktrace for details.
> [mxunittask] javax.net.ssl.SSLHandshakeException:
> sun.security.validator.ValidatorException: PKIX path building failed:
> sun.security.provider.certpath
> .SunCertPathBuilderException: unable to find valid certification path to
> requested target
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1623)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:198)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:192)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHands­haker.java:1074)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshak­er.java:128)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:529)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:465)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:88­4)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocke­tImpl.java:1120)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:6­23)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
> [mxunittask]    at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
> [mxunittask]    at
> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpC­onnection.java:828)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.ja­va:2116)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:10­96)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMetho­dDirector.java:398)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDi­rector.java:171)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
> [mxunittask]    at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
> [mxunittask]    at org.mxunit.ant.HttpHelper.runTest(HttpHelper.java:203)
> [mxunittask]    at
> org.mxunit.ant.MXUnitAntTask.doTest(MXUnitAntTask.java:317)
> [mxunittask]    at
> org.mxunit.ant.MXUnitAntTask.runDirectoryTests(MXUnitAntTask.java:307)
> [mxunittask]    at
> org.mxunit.ant.MXUnitAntTask.execute(MXUnitAntTask.java:222)
> [mxunittask]    at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
> [mxunittask]    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
> Source)
> [mxunittask]    at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp­l.java:25)
> [mxunittask]    at java.lang.reflect.Method.invoke(Method.java:597)
> [mxunittask]    at
> org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
> [mxunittask]    at org.apache.tools.ant.Task.perform(Task.java:348)
> [mxunittask]    at org.apache.tools.ant.Target.execute(Target.java:390)
> [mxunittask]    at org.apache.tools.ant.Target.performTasks(Target.java:411)
> [mxunittask]    at
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
> [mxunittask]    at
> org.apache.tools.ant.Project.executeTarget(Project.java:1366)
> [mxunittask]    at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.­java:41)
> [mxunittask]    at
> org.apache.tools.ant.Project.executeTargets(Project.java:1249)
> [mxunittask]    at org.apache.tools.ant.Main.runBuild(Main.java:801)
> [mxunittask]    at org.apache.tools.ant.Main.startAnt(Main.java:218)
> [mxunittask]    at
> org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
> [mxunittask]    at
> org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
> [mxunittask] Caused by: sun.security.validator.ValidatorException: PKIX path
> building failed: sun.security.provider.certpath.SunCertPathBuilderExcepti
> on: unable to find valid certification path to requested target
> [mxunittask]    at
> sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:325)
> [mxunittask]    at
> sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:219)
> [mxunittask]    at
> sun.security.validator.Validator.validate(Validator.java:218)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManager­Impl.java:126)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509Tr­ustManagerImpl.java:209)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509Tr­ustManagerImpl.java:249)
> [mxunittask]    at
> com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHands­haker.java:1053)
> [mxunittask]    ... 36 more
> [mxunittask] Caused by:
> sun.security.provider.certpath.SunCertPathBuilderException: unable to find
> valid certification path to requested target
> [mxunittask]    at
> sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBu­ilder.java:174)

Raymond Camden

unread,
Jan 12, 2011, 3:25:21 PM1/12/11
to mxu...@googlegroups.com
Any suggestions on how to get Ant to trust the ssl cert being used by the remote site?

denstar

unread,
Jan 12, 2011, 3:39:09 PM1/12/11
to mxu...@googlegroups.com
On Wed, Jan 12, 2011 at 1:25 PM, Raymond Camden wrote:
> Any suggestions on how to get Ant to trust the ssl cert being used by the
> remote site?

You can add it to the default certificate store... basically the same
routine you go through to get CF to trust a self-signed cert.

As far as I know, there's no simple "set this system property:
trust=true" type of deal, but that doesn't mean there isn't one. =)

There's also some code changes that could be done to use a "trust
everything" SSL context, but that would only be cool if you could turn
it on and off, I reckon.

:Den

--
Testimony should be a philosophical problem and not limited to legal
or historical contexts where it refers to the account of a witness who
reports what he has seen.
Paul Ricoeur

Raymond Camden

unread,
Jan 12, 2011, 5:31:57 PM1/12/11
to mxu...@googlegroups.com
No luck so far. Tried importing the site certificate using keytool and it report sok - but running the ant task again gives me the exact same issue.

Marc Esher

unread,
Jan 12, 2011, 6:20:18 PM1/12/11
to mxu...@googlegroups.com
Is it the same both inside and outside of eclipse?

On Wed, Jan 12, 2011 at 5:31 PM, Raymond Camden <rca...@gmail.com> wrote:
> No luck so far. Tried importing the site certificate using keytool and it
> report sok - but running the ant task again gives me the exact same issue.
>

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

bill shelton

unread,
Jan 12, 2011, 8:25:07 PM1/12/11
to mxu...@googlegroups.com
Ray,

Looks like the cert is self signed, true? 

bill

Raymond Camden

unread,
Jan 13, 2011, 10:42:07 AM1/13/11
to mxunit
I'm doing this 100% through command line right now.

On Jan 12, 5:20 pm, Marc Esher <marc.es...@gmail.com> wrote:
> Is it the same both inside and outside of eclipse?
>
> On Wed, Jan 12, 2011 at 5:31 PM, Raymond  Camden <rcam...@gmail.com> wrote:
>

Raymond Camden

unread,
Jan 13, 2011, 10:42:34 AM1/13/11
to mxunit
Yes. This is just for internal testing only. No need for anything to
work outside of our network.

bill shelton

unread,
Jan 13, 2011, 1:02:27 PM1/13/11
to mxu...@googlegroups.com
Ray,
 
This will require an enhancement to the MXUnit Ant task so that it will accept self-signed or untrusted SSL certificates.  The good news is that HttpClient 3.x provides an EasySSLProtocolSocketFactory class that may work. I'll look into it today to see what's involved. Of course, if anyone is interested in picking this up and running with it, I assure you that you will get no push-back whatsoever  ;-)
 
best,
bill

bill shelton

unread,
Jan 14, 2011, 10:42:06 AM1/14/11
to mxu...@googlegroups.com
Ray,
 
Working on this today ... can you try one thing? It's a shot in the dark, but I'd like to rule it out. Change your build file to the following:
 
<mxunittask
   server="the server..."
   connectionMethod="https"
   port="443"
   defaultrunner="${test.runner}"
   outputdir="${output.dir}"
   verbose="true">
 
  <directory path="${test.dir.location}"
             recurse="true"
             componentPath="stuff.unittests"  />
 </mxunittask>
 
bill
 
 
 

bill shelton

unread,
Jan 14, 2011, 10:42:58 AM1/14/11
to mxu...@googlegroups.com

bill shelton

unread,
Jan 14, 2011, 3:48:15 PM1/14/11
to mxu...@googlegroups.com
Ray,
 
 
Make sure to add the connectionMethod="https" and the SSL port; e.g., port="443".

Raymond Camden

unread,
Jan 17, 2011, 10:46:52 AM1/17/11
to mxunit
Woot! We have a winner. Thank you VERY much!

On Jan 14, 2:48 pm, bill shelton <vir...@gmail.com> wrote:
> Ray,
>
> Try this newer build:  http://mxunit.googlecode.com/svn/org.mxunit.ant.idea/trunk/dist/mxuni...

bill shelton

unread,
Jan 17, 2011, 3:14:54 PM1/17/11
to mxu...@googlegroups.com
Glad it worked, Ray. I'll do a little more clean up and commit to the MXUnit trunk and update the docs.

For those interested, the issue was due to a self signed certificate which the Ant task did not handle. The result was a fatal SSL handshake.  Since we use Apache HttpClient 3.x under the hood, we needed to set the SSLContext such that it accepts a "naive" TrustManager; in other words, a TrustManager that trusts all certificates. Obviously, this is not a good practice to do with production HTTP clients and servers, but for automated test builds in a non-production environment it's probably acceptable. (Comments or suggestions are welcome)

Further info: RFC 5246, TLS Protocol: http://tools.ietf.org/html/rfc5246 . Section 7.2.2, Error Alerts, explains some of the handshake contract.

bill 

Marc Esher

unread,
Jan 17, 2011, 6:41:44 PM1/17/11
to mxu...@googlegroups.com
Great job, Bill. Thanks for the explanation, too.

marc

bill shelton

unread,
Jan 25, 2011, 6:59:07 AM1/25/11
to mxu...@googlegroups.com
This fix has been committed to the mxunit framework trunk and is available for general distribution via SVN and github.

One minor note is that you should use protocol instead of connectionMethod to specifiy http or https.  protocol seems clearer and is now documented on the wiki (though both attributes are semantically equivalent and both will work).

bill
Reply all
Reply to author
Forward
0 new messages