URL theFolderUrl = Z.context.getResource(tabCornerDir);
if (theFolderUrl == null) return tabColorGifs;
javax.naming.directory.DirContext jndd = (javax.naming.directory.DirContext)theFolderUrl.getContent();
//This last line produces a ClassCastException under weblogic
'weblogic.kernel.Default (self-tuning)' Exception =
java.lang.ClassCastException: sun.net.www.content.text.PlainTextInputStream
cannot be cast to javax.naming.directory.DirContext
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
If the content type is plain text for a directory (as it is under weblogic), you can get the content of the url as an InputStream and read it.
I found that the InputStream returns a line (terminated by cr-lf) for each filename entry in the directory.
This turned out to be sufficient for my needs, so now the code parses the content in two ways:
1. as a directory under tomcat, and
2. as a plain text input stream under weblogic
I assume it is JRockit that is responsible for this rather odd content delivery, which could be considered a bug.
See the attached code snippet for details.
Open in new window