0 Replies Latest reply on Sep 11, 2002 6:04 PM by Gary Graham

    How do I accomplish relative addressing under JBoss?

    Gary Graham Newbie

      Hello all,

      I am an absolute newbie to JBoss. I have been working with a small wireless demo application that has been deployed as a war file under JBoss 2.2.2 and Tomcat 3.3.3 on a Linux server running apache. (forced to use these versions for now)

      The war file directory structure is:

      wirelesstt.war
      |
      |_WEB-INF
      | |_web.xml
      | |_classes
      | | |_various class files
      | | (mostly serveletts and action classes)
      | | I also have a copy of dbproperties.xml
      | | here
      | |_lib
      | |_my jar files (including the ConnPool.jar)
      | |_ and dbproperties.xml
      |
      |_ wireless_images
      a couple of image files

      I mention the ConnPool.jar file specifically above because this application uses connection pooling and this is the jar that handles it. The PoolManager class in this jar file needs to read a configuratiuon file named 'dbproperties.xml' which contains info about the pools to create, the jdbc drivers, etc.

      My problem is this: I need to be able to address this xml file via relative addressing. I do not seem to be able to do this.

      Here is the section of code from PoolManager that is trying to open the URL to the properties file:

      String urlstr = "/lib/dbproperties.xml";
      String linein = "";
      StringBuffer sb = new StringBuffer();
      URL myURL = null;
      BufferedReader br = null;
      System.out.println("In ConnPool.PoolManager.init()");
      try {
      System.out.println("attempting to load " + urlstr);
      myURL = new URL(urlstr);
      br = new BufferedReader(new InputStreamReader(myURL.openStream()));
      while ((linein = br.readLine()) != null) {
      sb.append(linein);
      }
      xmlStr = sb.toString();
      System.out.println("xmlStr created: " + xmlStr);
      br.close();

      }
      catch (MalformedURLException mue) {
      System.out.println("Can't read the properties file. (" + urlstr + ") at " + (new java.util.Date()));
      System.out.println("MalformedURLException Exception text: " + mue.getMessage());
      return;
      }
      catch(IOException ioe) {
      System.out.println("Can't read the properties file. (" + urlstr + ") at " + (new java.util.Date()));
      System.out.println("IOException text: " + ioe.getMessage());
      return;
      }
      catch (Exception e)
      {
      System.out.println("Can't read the properties file. (" + urlstr + ") at " + (new java.util.Date()));
      System.out.println("Exception text: " + e.getMessage());
      return;
      }


      As you can see all I am trying to do is create a Url object using a relative address and then use this object to create a BufferedReader to read in the xml.

      No matter how I try to configure the relative address:

      ./dbproperties.xml, wirelesstt/servlet/dbproperties.xml, etc I always get the following exception:

      [EmbeddedTomcatSX] In ConnPool.PoolManager.init()
      [EmbeddedTomcatSX] attempting to load /dbproperties.xml
      [EmbeddedTomcatSX] Can't read the properties file. (/dbproperties.xml) at Wed Sep 11 16:56:30 EDT 2002
      [EmbeddedTomcatSX] IOException text: /dbproperties.xml

      It appears that i can not locate the file.

      Can anyone help me with how to specify the relative address correctly? I am thoroughly confused and somewhat frustrated with JBoss as well. This technique works just fine under JRun, and under IIS.

      Thanks,

      Gary Graham