title: TeamCity fails deploying to Artifactory - reports "Expected a folder but found a file"
body: <p>I have a Maven build that was recently working and properly deploying, and now it fails to deploy. As far as I can tell, nothing has changed in the build settings nor the pom.xml. <em>(I did a diff on the pom from the successful and failing folders and they are identical; assuming the folder hasn't been updated.)</em></p>
  
  <p>The balance of the Maven builds are able to deploy. I'm using the same template for all projects, and the same settings.xml file as well.</p>
  
  <p>The build completes successfully, and then things get weird. I've looked at the logs from both builds in TeamCity and the command seems the same, other than the failure (which quits at that point).</p>
  
  <h2>Things that I've noticed:</h2>
  
  <ol>
  <li>The failing log message in Artifactory issues a <code>mkdir</code> command,</li>
  <li>then later warns about expecting a directory but found a file,</li>
  <li>which searching for that phrase, I found the exception class. <a href="http://subversion.jfrog.org/artifactory/public/trunk/base/api/src/main/java/org/artifactory/api/repo/exception/FolderExpectedException.java" rel="nofollow"><code>FolderExpectedException</code></a> for Artifactory.</li>
  <li>The log in TeamCity looks the same up until the failure.</li>
  <li>Other Maven builds (using same build template &amp; settings.xml file) successfully deploy.</li>
  <li>I ran diff against the succeeding and failing poms and there were no differences.</li>
  <li>Currently, I do not have the successful log from Artifactory; I'm going to dig on the machine though and see if I can find older logs.</li>
  <li>In both work directories on the build agents (successful &amp; not), the jar is at <code>target/mylib.jar</code></li>
  <li>Max unique snapshots are set to 0, so I don't think this is related to <a href="https://www.jfrog.com/jira/browse/RTFACT-3914" rel="nofollow">this older bug.</a></li>
  <li>If I move the snapshots out of libs-snapshot-local to a blacklisted repository and tried deploying again... it will create the <code>5-6-0-SNAPSHOT</code> root folder, but then it creates empty subfolders named the same as the jar and pom! But the artifact in TeamCity at target/mylib.jar is most definitely a jar file.</li>
  <li>TeamCity 8.0.4 build 27616; Artifactory 3.0.1 rev 30008 </li>
  <li>TeamCity was recently upgraded from 8.0.2, and the deployment was working at that point. I have not tried rolling it back, but other builds based on the same build template are successfully deploying, so I do not think that's it, but that may be the next thing to check.</li>
  <li>Artifact paths (from general settings) is: <code>**/*.jar</code></li>
  <li>The account that this is run under is a domain account and is not locked out. It has full control of the TeamCity Build Agent directories on each build machine.</li>
  </ol>
  
  <h2>Questions:</h2>
  
  <ol>
  <li>What else can I look for?</li>
  <li>Is there something I can try changing?</li>
  <li>Is there anything I can do to export everything TeamCity saw on the successful build versus the failing build now?</li>
  </ol>
  
  <p><em>TeamCity log - successful</em></p>
  
  <pre><code>[Step 1/1] Publishing artifacts  
  [Publishing artifacts] Collecting files to publish:  
      [E:\TCBuildAgent\temp\buildTmp\.tc-maven-bi\maven-build-info.xml.gz  
      =&gt; .teamcity]  
  [Publishing artifacts] Sending  
      E:/TCBuildAgent/temp/buildTmp/.tc-maven-bi/maven-build-info.xml.gz  
  [Step 1/1] Deploying artifacts to http://myserver.com:8081/artifactory  
  [Step 1/1] Deploying artifact:  
      http://myserver.com:8081/artifactory/libs-snapshot-local/  
      com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar  
  [11:07:24][Step 1/1] Deploying artifact:  
      http://myserver.com:8081/artifactory/libs-snapshot-local/  
      com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.pom  
  [11:07:27][Step 1/1] Deploying build info ...  
  [11:07:27][Step 1/1] Deploying build info to:  
      http://myserver.com:8081/artifactory/api/build  
  </code></pre>
  
  <p><em>TeamCity log - failure</em></p>
  
  <pre><code>[Step 1/1] Publishing artifacts  
  [Publishing artifacts] Collecting files to publish: 
      [E:\TCBuildAgent\temp\buildTmp\.tc-maven-bi\maven-build-info.xml.gz =&gt; 
      .teamcity]  
  [Publishing artifacts] Sending 
      E:/TCBuildAgent/temp/buildTmp/.tc-maven-bi/maven-build-info.xml.gz  
  [Step 1/1] Deploying artifacts to http://myserver.com:8081/artifactory  
  [Step 1/1] Deploying artifact: 
      http://myserver.com:8081/artifactory/libs-snapshot-local/
      com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar  
  [Step 1/1] Error deploying artifact: 
      E:\TCBuildAgent\work\2e99f45d5745c8fa\target\mylib.jar. Skipping 
      deployment of remaining artifacts (if any) and build info.  
  </code></pre>
  
  <p><em>Artifactory log - failure - <strong>note the <code>mkdir -p</code> command on the jar</strong></em></p>
  
  <pre><code>2013-10-08 18:00:23,718 [http-bio-8081-exec-1424] [INFO ]  
      (o.a.e.UploadServiceImpl:263) - MKDir request to  
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar'  
  2013-10-08 18:00:23,734 [http-bio-8081-exec-1424] [WARN ]  
      (o.a.s.f.l.SessionLockEntry:111) - Mutable item  
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar'  
      has local modifications that will be discarded.  
  2013-10-08 18:00:23,734 [http-bio-8081-exec-1424] [ERROR]  
      (o.a.w.s.RepoFilter :206) - Sending HTTP error code 500: Expected a folder  
      but found a file, at:  
      libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar  
  2013-10-08 18:00:23,734 [http-bio-8081-exec-1425] [INFO ]  
      (o.a.e.UploadServiceImpl:263) - MKDir request to  
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar'  
  2013-10-08 18:00:23,749 [http-bio-8081-exec-1425] [WARN ]  
      (o.a.s.f.l.SessionLockEntry:111) - Mutable item  
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar'  
      has local modifications that will be discarded.  
  2013-10-08 18:00:23,749 [http-bio-8081-exec-1425] [ERROR]  
      (o.a.w.s.RepoFilter :206) - Sending HTTP error code 500: Expected a folder  
      but found a file, at:  
      libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar  
  </code></pre>
  
  <p><em>The relevant pom.xml entries %&lt;-- snip:</em></p>
  
  <pre><code>&lt;groupId&gt;com.company.myapp&lt;/groupId&gt;
  &lt;artifactId&gt;mylib&lt;/artifactId&gt;
  &lt;version&gt;5.6.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;name&gt;mylib&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;maven.build.timestamp.format&gt;yyyy.MM.dd:HH.mm&lt;/maven.build.timestamp.format&gt;
      &lt;main.package&gt;com.company.myapp&lt;/main.package&gt;
      &lt;build.time&gt;${maven.build.timestamp}&lt;/build.time&gt;
  &lt;/properties&gt;
  
  &lt;distributionManagement&gt;
      &lt;snapshotRepository&gt;
          &lt;id&gt;ciassets&lt;/id&gt;
          &lt;name&gt;ciassets-snapshots&lt;/name&gt;
          &lt;url&gt;http://myserver.com:8081/artifactory/libs-snapshot-local&lt;/url&gt;
      &lt;/snapshotRepository&gt;
  &lt;/distributionManagement&gt;
  </code></pre>
  
  <p><em>The Artifactory logfile when it creates the directories instead of the poms:</em></p>
  
  <pre><code>2013-10-08 19:12:19,198 [http-bio-8081-exec-1454] [INFO ] 
      (o.a.e.UploadServiceImpl:263) - MKDir request to 
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar'
  2013-10-08 19:12:19,214 [http-bio-8081-exec-1454] [INFO ] 
      (o.a.e.UploadServiceImpl:269) - Directory 
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.jar' 
      was created successfully.
  2013-10-08 19:12:19,448 [http-bio-8081-exec-1454] [INFO ] 
      (o.a.e.UploadServiceImpl:263) - MKDir request to 
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.pom'
  2013-10-08 19:12:19,464 [http-bio-8081-exec-1454] [INFO ] 
      (o.a.e.UploadServiceImpl:269) - Directory 
      'libs-snapshot-local:com/company/myapp/mylib/5.6.0-SNAPSHOT/mylib-5.6.0-SNAPSHOT.pom' 
      was created successfully.
  2013-10-08 19:12:19,682 [http-bio-8081-exec-1454] [INFO ] 
      (o.a.r.r.c.BuildResource:280) - Adding build 
      'Java Stack :: My App - branch 5.6.0/ #9_412'
  2013-10-08 19:12:19,792 [http-bio-8081-exec-1454] [INFO ] 
      (o.a.r.r.c.BuildResource:296) - Added build 
      'Java Stack :: My App - branch 5.6.0/ #9_412'
  </code></pre>