我的Servlet应用程序使用XML目录。

首先,我使用org.apache.xml.resolver.tools.CatalogResolver
它在CatalogManager.properties下找到其配置文件WEB-INF/classes/

然后,我使用com.sun.org.apache.xml.internal.resolver.CatalogManager(JDK随附的版本)尝试了相同的操作。

它不起作用:

Cannot find CatalogManager.properties


规范说该文件必须在CLASSPATH上的某个位置,我想是的。
我该怎么办?

最佳答案

实际上,它应该工作,代码相同,只是重新打包:

  propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
  InputStream in =
    CatalogManager.class.getResourceAsStream("/"+propertyFile);
  if (in==null) {
    if (!ignoreMissingProperties) {
      System.err.println("Cannot find "+propertyFile);
      // there's no reason to give this warning more than once
      ignoreMissingProperties = true;
    }
    return;
  }


该怎么办?尝试调试,设置断点并查看为什么它不起作用。

为什么仍然需要CatalogManager.properties?如果不这样做,则可以使用系统属性xml.catalog.ignoreMissing禁用错误消息。

10-04 19:47