OpenEJB
  1. OpenEJB
  2. OPENEJB-1005

org.apache.openejb.config.WebModule constructor throws StringIndexOutOfBoundsException on windows

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.0.1, 3.1, 3.1.1
    • Fix Version/s: 3.0.2, 3.1.1
    • Component/s: container system
    • Labels:
      None
    • Environment:
      Windows XP

      Description

      org.apache.openejb.config.WebModule constructor has the following line:

      contextRoot = jarLocation.substring(jarLocation.lastIndexOf('/'));

      On windows, the jarLocation does not contain a "/" since the file separator is "\". This is resulting in StringIndexOutOfBoundsException. Stack trace is given below:

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1762)
      at java.lang.String.substring(String.java:1735)
      at org.apache.openejb.config.WebModule.<init>(WebModule.java:51)
      at org.apache.openejb.config.DeploymentLoader.createWebModule(DeploymentLoader.java:544)
      at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:445)
      at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:154)
      ...

        Activity

        Vamsavardhana Reddy created issue -
        Vamsavardhana Reddy made changes -
        Field Original Value New Value
        Description org.apache.openejb.config.WebModule constructor has the following line:

        contextRoot = jarLocation.substring(jarLocation.lastIndexOf('/'));

        On windows, the jarLocation does not contain a "/" since the path separator is "\". This is resulting in StringIndexOutOfBoundsException. Stack trace is given below:

        java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1762)
        at java.lang.String.substring(String.java:1735)
        at org.apache.openejb.config.WebModule.<init>(WebModule.java:51)
        at org.apache.openejb.config.DeploymentLoader.createWebModule(DeploymentLoader.java:544)
        at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:445)
        at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:154)
                ...
        org.apache.openejb.config.WebModule constructor has the following line:

        contextRoot = jarLocation.substring(jarLocation.lastIndexOf('/'));

        On windows, the jarLocation does not contain a "/" since the file separator is "\". This is resulting in StringIndexOutOfBoundsException. Stack trace is given below:

        java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1762)
        at java.lang.String.substring(String.java:1735)
        at org.apache.openejb.config.WebModule.<init>(WebModule.java:51)
        at org.apache.openejb.config.DeploymentLoader.createWebModule(DeploymentLoader.java:544)
        at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:445)
        at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:154)
                ...
        Hide
        Vamsavardhana Reddy added a comment -

        The problem can be fixed by replacing the line
        contextRoot = jarLocation.substring(jarLocation.lastIndexOf('/'));
        with
        contextRoot = jarLocation.substring(jarLocation.lastIndexOf(System.getProperty("file.separator")));

        Show
        Vamsavardhana Reddy added a comment - The problem can be fixed by replacing the line contextRoot = jarLocation.substring(jarLocation.lastIndexOf('/')); with contextRoot = jarLocation.substring(jarLocation.lastIndexOf(System.getProperty("file.separator")));
        Hide
        Vamsavardhana Reddy added a comment -

        Wondering if the fix can get into 3.0.1.

        Show
        Vamsavardhana Reddy added a comment - Wondering if the fix can get into 3.0.1.
        Hide
        Vamsavardhana Reddy added a comment -

        Didn't realize 3.0.1 is already out of the door

        Show
        Vamsavardhana Reddy added a comment - Didn't realize 3.0.1 is already out of the door
        Kevan Miller made changes -
        Assignee Kevan Miller [ kevan ]
        Hide
        Kevan Miller added a comment -

        Fixed in 3.0.2-SNAPSHOT and 3.1.1-SNAPSHOT. Thanks Vamsi!

        Show
        Kevan Miller added a comment - Fixed in 3.0.2-SNAPSHOT and 3.1.1-SNAPSHOT. Thanks Vamsi!
        Kevan Miller made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.0.1 [ 12313633 ]
        Resolution Fixed [ 1 ]
        Vamsavardhana Reddy made changes -
        Fix Version/s 3.0.2 [ 12314759 ]
        David Blevins made changes -
        Fix Version/s 3.1.x [ 12312806 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        41d 11h 55m 1 Kevan Miller 15/Apr/09 21:16

          People

          • Assignee:
            Kevan Miller
            Reporter:
            Vamsavardhana Reddy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development