列出WebDAV'__properties'文件夹时如何摆脱CmsVfsResourceNotFoundException的opencms?

时间:2012-08-01 19:16:29

标签: opencms

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

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

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

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


注释

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

2 设置每个可能文件的content-encoding属性,将dir设置为UTF-8没有用(stacktrace声称它丢失了)。


我的相关环境和设置:

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>

stacktrace:

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

1 个答案:

答案 0 :(得分: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存储库名称。)