How to get rid in opencms of the CmsVfsResourceNotFoundException when listing WebDAV '__properties' folders?

百般思念 提交于 2020-01-17 04:10:10

问题


With the standard OpenCms WebDAV config, you can get a CmsVfsResourceNotFoundException error when accessing resources via WebDAV.

This is very annoying, because whenever you list the content of any __properties folder, OpenCms dumps 36 stacktrace loglines per file in that folder! If you scan your WebDAV dirs often during debugging (see note 1), these logs makes your life harder. (Of course, you could change the log level to something higher than INFO, but for me that's not acceptable.)

The issue is easily reproducible: point the browser to the opencms-exported webdav path, and click on any __properties dir.

I have found two workarounds, but I'm not really happy with any of them. Perhaps there is a better solution?


Notes

1 I'm debugging some OpenCms modules with NetBeans. I export their sources via OpenCms' WebDAV, and mount them in linux as davfs. If I add them to a NetBeans project, it automatically scans this mounted file hierarchy, resulting in OpenCms getting 'berserk' and beginning to overflow my poor console with useless traces. It gets worse, as NetBeans periodically re-scans these directories.

2 Setting the content-encoding property of every possible file and dir to UTF-8 does not help (the stacktrace claims it is missing).


My relevant environment and settings:

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 relevant config:

<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>  

My opencms-importexport.xml relevant config:

<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>

My opencms-system.xml relevant config:

<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>

The 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:


I have found two work arounds:

Edit the filter regex to exclude the '__properties' dirs.

In 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>

(Don't forget to update your web.xml to change the webdav repository name.)

Remove the 'CmsResourceWrapperPropertyFile' from the repository.

In 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>

(Again, don't forget to update your web.xml to change the webdav repository name.)



来源:https://stackoverflow.com/questions/11765997/how-to-get-rid-in-opencms-of-the-cmsvfsresourcenotfoundexception-when-listing-we

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!