Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3840

problem with URLHandlers when running 2 frameworks in one jvm in separate class loaders

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • framework-4.0.2, framework-4.0.3
    • framework-4.2.0
    • Framework
    • None
    • windows 7 64bit

    Description

      This bug happens with 4.0.2 and 4.1.0-SNAPSHOT framework versions.
      Run embedded felix with tomcat as describe in http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html and as shown in http://heapdump.wordpress.com/2010/03/25/osgi-enabled-war/

      One war activate Felix and works great. Adding another war gives the below error :
      "Unable to update the bundle. (java.net.MalformedURLException: Unknown protocol: obr"

      After debugging I saw the problem is generally in the URLHandlers classes implementation.
      In URLHandlersStreamHandlerProxy class the getStreamHandlerService function does not return the correct value. The below code fails since framework is from current webapp class loader and Felix is from first webapp class loader
      if (framework instanceof Felix)
      {
      service = ((Felix) framework).getStreamHandlerService(m_protocol);
      }
      so we try to execute the below code and fail with method not recognize error
      service = m_action.invoke(
      m_action.getMethod(framework.getClass(), "getStreamHandlerService", STRING_TYPES),
      framework, new Object[]

      {m_protocol}

      );

      After I set getStreamHandlerService function to public in Felix class it works.

      Then in URLHandlersStreamHandlerProxy class the below function fails (for the setURL method) since m_service is null

      public Object invoke(Object obj, Method method, Object[] params)
      throws Throwable
      {
      try
      {
      Class[] types = method.getParameterTypes();
      if ("parseURL".equals(method.getName()))
      {
      types[0] = m_service.getClass().getClassLoader().loadClass(
      URLStreamHandlerSetter.class.getName());
      params[0] = Proxy.newProxyInstance(
      m_service.getClass().getClassLoader(), new Class[]

      {types[0]}

      ,
      (URLHandlersStreamHandlerProxy) params[0]);
      }
      return m_action.invokeDirect(m_action.getMethod(m_service.getClass(),
      method.getName(), types), m_service, params);
      }
      catch (Exception ex)

      { throw ex; }

      }

      Attachments

        Activity

          People

            karlpauls Karl Pauls
            itay.hindy itay hindy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: