0

使用标准的 OpenCms WebDAV 配置,CmsVfsResourceNotFoundException通过 WebDAV 访问资源时可能会出错。

这很烦人,因为每当您列出任何__properties文件夹的内容时,OpenCms 都会转储该文件夹中每个文件的 36 个堆栈跟踪日志行!如果您在调试期间经常扫描 WebDAV 目录(请参阅注 1),这些日志会让您的生活更加艰难。(当然,您可以将日志级别更改为高于INFO,但对我来说这是不可接受的。)

该问题很容易重现:将浏览器指向 opencms 导出的 webdav 路径,然后单击任何__properties目录。

我找到了两种解决方法,但我对其中任何一种都不满意。也许有更好的解决方案?


笔记

1我正在使用 NetBeans 调试一些 OpenCms 模块。我通过 OpenCms 的 WebDAV 导出它们的源代码,并将它们安装在 linux 中作为davfs. 如果我将它们添加到 NetBeans 项目,它会自动扫描这个挂载的文件层次结构,导致 OpenCms 变得“狂暴”,并开始用无用的痕迹溢出我可怜的控制台。情况变得更糟,因为 NetBeans 会定期重新扫描这些目录。

2content-encoding每个可能的文件和目录的属性设置为 UTF-8 并没有帮助(堆栈跟踪声称它丢失了)。


我的相关环境和设置:

INFO OpenCms version      : 8.0.3
INFO System file.encoding : UTF-8
INFO i18n configuration   : the JVM default locale is "en"
INFO Initializing WebDAV servlet
INFO Initialized param "listings" with value "true"
INFO Initialized param "readonly" with value "false"
INFO Using repository with name "standard"

web.xml相关配置:

<servlet>
    <description>
        Creates an access to OpenCms through WebDAV.
    </description>
    <servlet-name>OpenCmsWebDavServlet</servlet-name>
    <servlet-class>org.opencms.webdav.CmsWebdavServlet</servlet-class>
    <init-param>
      <param-name>listings</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>readonly</param-name>
      <param-value>false</param-value>
    </init-param>
    <init-param>
      <param-name>repository</param-name>
      <param-value>standard</param-value>
    </init-param>
</servlet>  

我的opencms-importexport.xml相关配置:

<repositories>
    <repository name="standard" class="org.opencms.repository.CmsRepository">
        <params>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceExtensionWrapperJsp</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceExtensionWrapperXmlContent</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceExtensionWrapperXmlPage</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceWrapperSystemFolder</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceWrapperPropertyFile</param>
        </params>
        <filter type="include">
            <regex>/</regex>
            <regex>/__properties/.*</regex>
            <regex>/sites/.*</regex>
            <regex>/system/</regex>
            <regex>/system/__properties/.*</regex>
            <regex>/system/galleries/.*</regex>
            <regex>/system/modules/.*</regex>
            <regex>/system/workplace/.*</regex>
        </filter>
    </repository>

我的opencms-system.xml相关配置:

<opencms>
  <system>
    <internationalization>
      <localehandler class="org.opencms.i18n.CmsDefaultLocaleHandler"/>
      <localesconfigured>
        <locale>en</locale>
        <locale>de</locale>
      </localesconfigured>
      <localesdefault>
        <locale>en</locale>
        <locale>de</locale>
      </localesdefault>
      <timezone>GMT+01:00</timezone>
    </internationalization>

堆栈跟踪:

01 Aug 2012 18:09:05,607  INFO [.opencms.i18n.CmsLocaleManager: 311] Could not read encoding property for resource "/sites/default/.content/config/__properties/c_0001.html.properties".
org.opencms.file.CmsVfsResourceNotFoundException: Error reading the property value for property "content-encoding" of resource "/.content/config/__properties/c_0001.html.properties".
    at org.opencms.file.CmsVfsResourceNotFoundException.createException(CmsVfsResourceNotFoundException.java:71)
    at org.opencms.db.CmsDbContext.throwException(CmsDbContext.java:334)
    at org.opencms.db.CmsDbContext.report(CmsDbContext.java:286)
    at org.opencms.db.CmsSecurityManager.readPropertyObject(CmsSecurityManager.java:4405)
    at org.opencms.file.CmsObject.readPropertyObject(CmsObject.java:2681)
    at org.opencms.i18n.CmsLocaleManager.getResourceEncoding(CmsLocaleManager.java:305)
    at org.opencms.file.wrapper.CmsObjectWrapper.needUtf8Marker(CmsObjectWrapper.java:871)
    at org.opencms.file.wrapper.CmsObjectWrapper.getResourcesInFolder(CmsObjectWrapper.java:382)
    at org.opencms.repository.CmsRepositorySession.list(CmsRepositorySession.java:268)
    at org.opencms.webdav.CmsWebdavServlet.renderHtml(CmsWebdavServlet.java:2480)
    at org.opencms.webdav.CmsWebdavServlet.serveResource(CmsWebdavServlet.java:2727)
    at org.opencms.webdav.CmsWebdavServlet.doGet(CmsWebdavServlet.java:1208)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at org.opencms.webdav.CmsWebdavServlet.service(CmsWebdavServlet.java:2893)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.opencms.file.CmsVfsResourceNotFoundException: Unable to read resource "/.content/config/__properties".
    at org.opencms.db.generic.CmsVfsDriver.readResource(CmsVfsDriver.java:2162)
    at org.opencms.db.CmsDriverManager.readResource(CmsDriverManager.java:7293)
    at org.opencms.db.CmsDriverManager.readPropertyObjects(CmsDriverManager.java:7110)
    at org.opencms.db.CmsDriverManager.readPropertyObject(CmsDriverManager.java:7043)
    at org.opencms.db.CmsSecurityManager.readPropertyObject(CmsSecurityManager.java:4403)
    ... 23 more
4

1 回答 1

1

我找到了两种解决方法:

编辑过滤器正则表达式以排除“__properties”目录。

opencms-importexport.xml

   <repository name="webdavrep" class="org.opencms.repository.CmsRepository">
        <params><!-- don't change it --></params>
        <filter type="include">
            <regex>/</regex>
            <regex>/__properties/.*</regex>
            <regex>/sites/((?!__properties).)*</regex>
            <!-- instead of ...
            <regex>/sites/.*</regex>
            -->
            <!-- etc -->
        </filter>
   </repository>

(不要忘记更新您的web.xml以更改 webdav 存储库名称。)

从存储库中删除“CmsResourceWrapperPropertyFile”。

opencms-importexport.xml

   <repository name="webdavrep" class="org.opencms.repository.CmsRepository">
        <params>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceExtensionWrapperJsp</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceExtensionWrapperXmlContent</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceExtensionWrapperXmlPage</param>
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceWrapperSystemFolder</param>
            <!-- Do not publish properties ...
            <param name="wrapper">org.opencms.file.wrapper.CmsResourceWrapperPropertyFile</param>
            -->
        </params>
        <filter type="include"><!-- don't change it --></filter>

(同样,不要忘记更新您的web.xml以更改 webdav 存储库名称。)

于 2012-08-01T19:16:29.230 回答