You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Karl Pauls (JIRA)" <ji...@apache.org> on 2013/02/01 22:18:12 UTC

[jira] [Resolved] (FELIX-3840) problem with URLHandlers when running 2 frameworks in one jvm in separate class loaders

     [ https://issues.apache.org/jira/browse/FELIX-3840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls resolved FELIX-3840.
-------------------------------

    Resolution: Fixed

As I said, the problem was that we didn't use the getDeclaredMethod. That was a problem since the classes are loaded by different classloaders. Now, we get the service even so the methods are not public.

Furthermore, there was a bug in the proxy (the nullpointer you did see). I fixed this as well. Please close this issue if it works for you (or reopen if not).
                
> problem with URLHandlers when running 2 frameworks in one jvm in separate class loaders
> ---------------------------------------------------------------------------------------
>
>                 Key: FELIX-3840
>                 URL: https://issues.apache.org/jira/browse/FELIX-3840
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-4.0.2, framework-4.0.3
>         Environment: windows 7 64bit
>            Reporter: itay hindy
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>
> 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;
> 	}
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira