I've created a Java class that connects to an IIS website requiring NTLM authentication. The Java class uses the JCIFS library and is based on the following example:
Config.registerSmbURLHandler();
Config.setProperty("jcifs.smb.client.domain", domain);
Config.setProperty("jcifs.smb.client.username", user);
Config.setProperty("jcifs.smb.client.password", password);
URL url = new URL(location);
BufferedReader reader = new BufferedReader(
new InputStreamReader(url.openStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
The example works fine when executed from the command prompt, but as soon as I try to use the same code in a servlet container (specifically GlassFish), I get an IOException
containing the message "Server returned HTTP response code: 401 for URL: ....".
I've tried moving the jcifs jar to the system classpath (%GLASSFISH%/lib), but that doesn't seem to make any difference.
Suggestions are highly appreciated.