ActiveMQ
  1. ActiveMQ
  2. AMQ-1883

KahaStore is unable to create lock file when user.dir is manually changed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 5.1.0
    • Fix Version/s: NEEDS_REVIEW
    • Component/s: Message Store
    • Labels:
      None
    • Environment:

      WinNTFileSystem
      jdk 1.6_05

      Description

      I've been getting the following exception

      Caused by: java.io.FileNotFoundException: activemq-data\localhost-kahastore\lock (The system cannot find the path specified)
      at java.io.RandomAccessFile.open(Native Method)
      at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
      at org.apache.activemq.kaha.impl.KahaStore.initialize(KahaStore.java:476)

      I assume that changeset 661435 <http://fisheye6.atlassian.com/changelog/activemq?cs=661435> was aimed to fix the problem following problem:
      Error in directory.mkdirs is masked and can result in FileNotFoundException when creating tmp_storage directory <http://open.iona.com/issues/browse/MB-360>

      I verified that there is no problem in creating the parent directories, but filesystem thinks that directory doesn't exists after it has been created succesfully. After little more digging I stumbled upon the following:
      File.getAbsolutePath() is incorrect if "user.dir" is set on the command line <http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4117557>

      There is some more information about using canonical form at Mule project <http://mule.mulesource.org/jira/browse/MULE-1112> and I found out that using getCanonicalFile() does indeed work.

      As a patch I suggest that all file/directory related methods at IOHelper would return (canonical) File instead of String.

      Other not so intrusive possibility would be to change XBeanBrokerService.
      KahaStore.<init>(File, String, AtomicLong) line: 103
      StoreFactory.open(File, String) line: 56
      XBeanBrokerService(BrokerService).getTempDataStore() line: 1178

        Activity

        Hide
        Tuomas Kiviaho added a comment -

        I found "org.apache.activemq.default.directory.prefix" system property that can be used to circumvent the problem in generic way is at maven plugin AMQ-1223.

        I think it would be helpful to mention this along with error message if canonical form can't be obtained. I found out XML configuration documentation disturbingly misleading <http://activemq.apache.org/xml-configuration.html> since it doesn't make use of the property.

        Mentioning this feature in documentation of persistence <http://activemq.apache.org/persistence.html> would prevent fist time mistakes such as mutilation of the 'user.dir' although IOUtils.getDefaultDirectoryPrefix() could use 'user.dir' fallback precaution instead of trusting on the file system manager.

        Show
        Tuomas Kiviaho added a comment - I found "org.apache.activemq.default.directory.prefix" system property that can be used to circumvent the problem in generic way is at maven plugin AMQ-1223 . I think it would be helpful to mention this along with error message if canonical form can't be obtained. I found out XML configuration documentation disturbingly misleading < http://activemq.apache.org/xml-configuration.html > since it doesn't make use of the property. Mentioning this feature in documentation of persistence < http://activemq.apache.org/persistence.html > would prevent fist time mistakes such as mutilation of the 'user.dir' although IOUtils.getDefaultDirectoryPrefix() could use 'user.dir' fallback precaution instead of trusting on the file system manager.
        Hide
        Timothy Bish added a comment -

        Will be deprecating Kaha and AMQ stores in 5.8

        Show
        Timothy Bish added a comment - Will be deprecating Kaha and AMQ stores in 5.8

          People

          • Assignee:
            Rob Davies
            Reporter:
            Tuomas Kiviaho
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development