wiseman
  1. wiseman
  2. WISEMAN-169

Product does not run with a war file on Weblogic Server

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: management
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: x86

    • Issuezilla Id:
      169

      Description

      Wiseman throws an NPE on Weblogic Server upon first access. The offending code
      is in com.sun.ws.management.server.servlet.WSManServlet, in methods getFilenames
      () and getQueryFilename().

      More specifically, the problem is in the use of the Java Servlet API method
      ServletContext.getRealPath() which, per the Javadoc, is allowed to return Null
      if the servlet container does not resolve resource locations to paths on disk.
      This method always returns Null on Weblogic.

      Here is a potential solution that works on both Weblogic and Tomcat.

      Original getFilenames() method:

      private List<String> getFilenames(ServletContext context, String path) {
      final List<String> xsdFilenames = new ArrayList<String>();

      final Set<String> xsdLocSet = context.getResourcePaths(path);

      if ((xsdLocSet == null) || (xsdLocSet.size() == 0))
      return xsdFilenames;

      final List<String> xsdLocList = new ArrayList<String>(xsdLocSet);
      final Iterator<String> xsdLocIterator = xsdLocList.iterator();

      // find the files and add them to the list
      // make a recursive call for directories
      for (int i = 0; xsdLocIterator.hasNext(); i++) {
      String xsdLoc = xsdLocIterator.next();
      final File f = new File(context.getRealPath(xsdLoc));
      if (f.isFile())

      { xsdFilenames.add(xsdLoc); }

      else

      { if (xsdLoc.charAt(xsdLoc.length() - 1) == '/') xsdLoc = xsdLoc.substring(0, xsdLoc.length() - 1); List<String> subList = getFilenames(context, xsdLoc); xsdFilenames.addAll(subList); }

      }
      return xsdFilenames;
      }

      Replacement:

      private List<String> getFilenames(ServletContext context, String path) {
      final List<String> xsdFilenames = new ArrayList<String>();
      final Set<String> xsdLocSet = context.getResourcePaths(path);

      if ((xsdLocSet == null) || (xsdLocSet.size() == 0))
      return xsdFilenames;

      final List<String> xsdLocList = new ArrayList<String>(xsdLocSet);
      final Iterator<String> xsdLocIterator = xsdLocList.iterator();

      // find the files and add them to the list
      // make a recursive call for directories
      for (int i = 0; xsdLocIterator.hasNext(); i++) {
      String xsdLoc = xsdLocIterator.next();
      try {
      URL url = context.getResource(xsdLoc);
      URI uri = url.toURI();
      final File f = new File(uri);
      if (f.isFile())

      { xsdFilenames.add(xsdLoc); }

      else

      { if (xsdLoc.charAt(xsdLoc.length() - 1) == '/') xsdLoc = xsdLoc.substring(0, xsdLoc.length() - 1); List<String> subList = getFilenames(context, xsdLoc); xsdFilenames.addAll(subList); }

      } catch (Exception e)

      { LOG.log(Level.SEVERE, "Error resolving schemas", e); }

      }
      return xsdFilenames;
      }

      And in getQueryFilename(), there is code that reads:

      final File f = new File(getServletContext().getRealPath(name));
      if (f.canRead() == true) { ...

      Replace it with:

      File f = null;
      try {
      URL url = getServletContext().getResource(name);
      URI uri = url.toURI();
      f = new File(uri);
      } catch (MalformedURLException e) {
      } catch (URISyntaxException e) {
      }
      if (f != null && f.canRead() == true) { ...

        Activity

        Hide
        denis_rachal added a comment -

        Taking ownership.

        Show
        denis_rachal added a comment - Taking ownership.

          People

          • Assignee:
            denis_rachal
            Reporter:
            bpbailey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: