ADF, ADF Desktop Integration (ADFdi), ADF Exceptions

ADFDI-00502: The client was unable to establish an unauthenticated session with the web application. What can be the reason?

I have experienced such error. The reason was, that web application didn’t know, that servlet “adfdiRemoteServlet”, responsible for Excel workbook connectivity, should be secured. Problem happens only when ADF security is set to “ADF Authentication and Authorization”. This means, that ADF takes care not just for login, but for access to various resources (in our case it is adfdiRemoteServlet) as well. When security is set to “ADF Authentication”, everything works fine without any additional configuration.
So what is the solution if You want to use ADF authentication and authorization as well? There is need to edit application web.xml file. You need to say, that adfdiRemoteServlet is also secured. To complete this, just append “security-constraint” XML element like this:

<security-constraint>
    <web-resource-collection>
      <web-resource-name>adfAuthentication</web-resource-name>
      <url-pattern>/adfAuthentication</url-pattern>
      <url-pattern>/adfdiRemoteServlet</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>valid-users</role-name>
    </auth-constraint>
  </security-constraint>

The line in bold is newly added. It is just additional URL pattern for adfdiRemoteServlet.
Thats it! It should work now.
This solution tested for ADF version 11.1.1.7