Qpid
  1. Qpid
  2. QPID-3971

PropertiesFileInitialContextFactory cannot open file URL

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.14
    • Fix Version/s: 0.17
    • Component/s: Java Client
    • Labels:
      None
    • Environment:

      MAC OS 10.7, java version "1.6.0_31"

      Description

      Hi all,

      I have to configure JNDI by a properties file. For example:

      String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";

      System.setProperty(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

      System.setProperty(Context.PROVIDER_URL, "path/to/file");

      Context context = new InitialContext();

      Everything works fine until the "Context.PROVIDER_URL" contains a "real" URL instead of a file path. In our example the "Context.PROVIDER_URL" is set by a third party library. But using an URL here causes an FileNotFoundException in [3].

      java.io.FileNotFoundException: file:/Users/.../qpid-jndi.conf (No such file or directory)

      at java.io.FileInputStream.open(Native Method)

      at java.io.FileInputStream.<init>(FileInputStream.java:120)

      at java.io.FileInputStream.<init>(FileInputStream.java:79)

      Looking at PropertiesFileInitialContextFactory (cf. [2] line 85) it's clear what happens. It tries to open the URL using a FileInputStream. At least on my Mac that doesn't work. My question is whether Qpid should be modified to accept File-URLs since Context.PROVIDER_URL is specified as an URL in [1] and apparently some libraries take it seriously...

      Many thanks,

      Tobias

      [1] http://docs.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL
      [2] http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java?view=markup

        Activity

        Weston M. Price made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Weston M. Price made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Weston M. Price made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 0.17 [ 12320179 ]
        Resolution Fixed [ 1 ]
        Weston M. Price made changes -
        Assignee Weston M. Price [ wprice ]
        Tobias Unger made changes -
        Field Original Value New Value
        Description Hi all,

        I have to configure JNDI by a properties file. For example:

        String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";

        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

        System.setProperty(Context.PROVIDER_URL, "path/to/file");

        Context context = new InitialContext();

        Everything works fine until the "Context.PROVIDER_URL" contains a "real" URL instead of a file path. In our example the "Context.PROVIDER_URL" is set by a third party library. But using an URL here causes an FileNotFoundException in [3].

        java.io.FileNotFoundException: file:/Users/.../qpid-jndi.conf (No such file or directory)

        at java.io.FileInputStream.open(Native Method)

        at java.io.FileInputStream.<init>(FileInputStream.java:120)

        at java.io.FileInputStream.<init>(FileInputStream.java:79)



        Looking at PropertiesFileInitialContextFactory [2] it's clear what happens. It tries to open the URL using a FileInputStream. At least on my Mac that doesn't work. My question is whether Qpid should be modified to accept File-URLs since Context.PROVIDER_URL is specified as an URL in [1] and apparently some libraries take it seriously...

        Many thanks,

        Tobias

        [1] http://docs.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL
        [2] http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java?view=markup
        Hi all,

        I have to configure JNDI by a properties file. For example:

        String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";

        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

        System.setProperty(Context.PROVIDER_URL, "path/to/file");

        Context context = new InitialContext();

        Everything works fine until the "Context.PROVIDER_URL" contains a "real" URL instead of a file path. In our example the "Context.PROVIDER_URL" is set by a third party library. But using an URL here causes an FileNotFoundException in [3].

        java.io.FileNotFoundException: file:/Users/.../qpid-jndi.conf (No such file or directory)

        at java.io.FileInputStream.open(Native Method)

        at java.io.FileInputStream.<init>(FileInputStream.java:120)

        at java.io.FileInputStream.<init>(FileInputStream.java:79)



        Looking at PropertiesFileInitialContextFactory (cf. [2] line 85) it's clear what happens. It tries to open the URL using a FileInputStream. At least on my Mac that doesn't work. My question is whether Qpid should be modified to accept File-URLs since Context.PROVIDER_URL is specified as an URL in [1] and apparently some libraries take it seriously...

        Many thanks,

        Tobias

        [1] http://docs.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL
        [2] http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java?view=markup
        Tobias Unger created issue -

          People

          • Assignee:
            Weston M. Price
            Reporter:
            Tobias Unger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development