You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Tim Moore (JIRA)" <ji...@apache.org> on 2008/11/20 02:01:45 UTC

[jira] Created: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
--------------------------------------------------------------------------------------

                 Key: FELIX-827
                 URL: https://issues.apache.org/jira/browse/FELIX-827
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: felix-1.4.0, felix-1.2.1

            Reporter: Tim Moore


I'm running Felix embedded inside a webapp, running in Tomcat.

Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)

I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by Karl Pauls <ka...@gmail.com>.
> What a mess! For now we just have to restart Tomcat every time we deploy a
> new build. We may not find a better solution, since even if all of Felix's
> leaks are fixed, it's been pointed out to me that other libraries such as
> commons-logging have reloading problems too. Oh well.

Care to share your insides with us as well? Maybe there is something
we can do...

Regarding leaks in general, we do take them seriously and will try to
trace down and fix them. In case of  the URLHandlers you are running
in a known limitation of the implementation I didn't have time to
refactor yet. For the time being, try to get my patch working and see
whether that makes a difference.

regards,

Karl

> Thanks,
> Tim
>
> On Dec 1, 2008, at 5:04 PM, Niclas Hedhman wrote:
>
>> Tim,
>> also beware that Sun's JVM caches a lot of the stuff in the resource
>> management system, and IIRC URLStreamHandlerFactories belong in that
>> category too, at least if used via the java.net.handler.pkgs system
>> property. Perhaps the setURLStreamHandlerFactory is better behaved,
>> but I suggest to check the actual sources to be sure.
>>
>>
>> Cheers
>> Niclas
>>
>> On Tue, Dec 2, 2008 at 1:41 AM, Tim Moore (JIRA) <ji...@apache.org> wrote:
>>>
>>>  [
>>> https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652219#action_12652219
>>> ]
>>>
>>> Tim Moore commented on FELIX-827:
>>> ---------------------------------
>>>
>>> Karl,
>>>
>>> Thanks for your response. I'll test the patch. Unfortunately, the problem
>>> with memory leaks in webapps is rather bad, because class objects contain a
>>> reference to their classloader, and the classloader then contains references
>>> to every class that it loaded. So if even one class object reference leaks
>>> from a webapp classloader to a parent loader, the entire classloader cannot
>>> be collected. This makes it very important for anything in a webapp that
>>> registers itself with an object in the system classloader to unregister when
>>> the webapp is unloaded. These problems can be very tricky to track down, and
>>> until every single leak is patched, the problem will remain.
>>>
>>>> URLHandlers does not restore the previous URLStreamHandlerFactory after
>>>> stopping Felix
>>>>
>>>> --------------------------------------------------------------------------------------
>>>>
>>>>               Key: FELIX-827
>>>>               URL: https://issues.apache.org/jira/browse/FELIX-827
>>>>           Project: Felix
>>>>        Issue Type: Improvement
>>>>        Components: Framework
>>>>  Affects Versions: felix-1.2.1
>>>
>>> , felix-1.4.0
>>>>
>>>>          Reporter: Tim Moore
>>>>          Assignee: Karl Pauls
>>>>           Fix For: felix-1.4.1
>>>>
>>>>       Attachments: felix-827.patch, leak.patch,
>>>> test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>>>>
>>>>
>>>> I'm running Felix embedded inside a webapp, running in Tomcat.
>>>> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out
>>>> correctly when I start it, and seems to delegate properly. When the webapp
>>>> is unloaded, however, and it stops Felix, it does not restore the previous
>>>> implementation, but rather leaves the existing URLHandlers instance
>>>> installed. Then, if I try to redeploy the webapp without restarting the JVM,
>>>> I get errors, because Tomcat automatically sets the URLHandlers class's
>>>> static members to null when it unloads the webapp. (see
>>>> https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
>>>> I've tested this on 1.2.1 and 1.4.0, and both versions have this
>>>> problem.
>>>
>>> --
>>> This message is automatically generated by JIRA.
>>> -
>>> You can reply to this email to add a comment to the issue online.
>>>
>>>
>
> --
> Tim Moore
> Atlassian Plugin Developer
>
>
>
>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: [jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by Tim Moore <tm...@atlassian.com>.
What a mess! For now we just have to restart Tomcat every time we  
deploy a new build. We may not find a better solution, since even if  
all of Felix's leaks are fixed, it's been pointed out to me that other  
libraries such as commons-logging have reloading problems too. Oh well.

Thanks,
Tim

On Dec 1, 2008, at 5:04 PM, Niclas Hedhman wrote:

> Tim,
> also beware that Sun's JVM caches a lot of the stuff in the resource
> management system, and IIRC URLStreamHandlerFactories belong in that
> category too, at least if used via the java.net.handler.pkgs system
> property. Perhaps the setURLStreamHandlerFactory is better behaved,
> but I suggest to check the actual sources to be sure.
>
>
> Cheers
> Niclas
>
> On Tue, Dec 2, 2008 at 1:41 AM, Tim Moore (JIRA) <ji...@apache.org>  
> wrote:
>>
>>   [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652219 
>> #action_12652219 ]
>>
>> Tim Moore commented on FELIX-827:
>> ---------------------------------
>>
>> Karl,
>>
>> Thanks for your response. I'll test the patch. Unfortunately, the  
>> problem with memory leaks in webapps is rather bad, because class  
>> objects contain a reference to their classloader, and the  
>> classloader then contains references to every class that it loaded.  
>> So if even one class object reference leaks from a webapp  
>> classloader to a parent loader, the entire classloader cannot be  
>> collected. This makes it very important for anything in a webapp  
>> that registers itself with an object in the system classloader to  
>> unregister when the webapp is unloaded. These problems can be very  
>> tricky to track down, and until every single leak is patched, the  
>> problem will remain.
>>
>>> URLHandlers does not restore the previous URLStreamHandlerFactory  
>>> after stopping Felix
>>> --------------------------------------------------------------------------------------
>>>
>>>                Key: FELIX-827
>>>                URL: https://issues.apache.org/jira/browse/FELIX-827
>>>            Project: Felix
>>>         Issue Type: Improvement
>>>         Components: Framework
>>>   Affects Versions: felix-1.2.1
>> , felix-1.4.0
>>>           Reporter: Tim Moore
>>>           Assignee: Karl Pauls
>>>            Fix For: felix-1.4.1
>>>
>>>        Attachments: felix-827.patch, leak.patch, test-felix- 
>>> handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>>>
>>>
>>> I'm running Felix embedded inside a webapp, running in Tomcat.
>>> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it  
>>> out correctly when I start it, and seems to delegate properly.  
>>> When the webapp is unloaded, however, and it stops Felix, it does  
>>> not restore the previous implementation, but rather leaves the  
>>> existing URLHandlers instance installed. Then, if I try to  
>>> redeploy the webapp without restarting the JVM, I get errors,  
>>> because Tomcat automatically sets the URLHandlers class's static  
>>> members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
>>> I've tested this on 1.2.1 and 1.4.0, and both versions have this  
>>> problem.
>>
>> --
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>>
>>

-- 
Tim Moore
Atlassian Plugin Developer





Re: [jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by Niclas Hedhman <ni...@hedhman.org>.
Tim,
also beware that Sun's JVM caches a lot of the stuff in the resource
management system, and IIRC URLStreamHandlerFactories belong in that
category too, at least if used via the java.net.handler.pkgs system
property. Perhaps the setURLStreamHandlerFactory is better behaved,
but I suggest to check the actual sources to be sure.


Cheers
Niclas

On Tue, Dec 2, 2008 at 1:41 AM, Tim Moore (JIRA) <ji...@apache.org> wrote:
>
>    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652219#action_12652219 ]
>
> Tim Moore commented on FELIX-827:
> ---------------------------------
>
> Karl,
>
> Thanks for your response. I'll test the patch. Unfortunately, the problem with memory leaks in webapps is rather bad, because class objects contain a reference to their classloader, and the classloader then contains references to every class that it loaded. So if even one class object reference leaks from a webapp classloader to a parent loader, the entire classloader cannot be collected. This makes it very important for anything in a webapp that registers itself with an object in the system classloader to unregister when the webapp is unloaded. These problems can be very tricky to track down, and until every single leak is patched, the problem will remain.
>
>> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
>> --------------------------------------------------------------------------------------
>>
>>                 Key: FELIX-827
>>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>>             Project: Felix
>>          Issue Type: Improvement
>>          Components: Framework
>>    Affects Versions: felix-1.2.1
> , felix-1.4.0
>>            Reporter: Tim Moore
>>            Assignee: Karl Pauls
>>             Fix For: felix-1.4.1
>>
>>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>>
>>
>> I'm running Felix embedded inside a webapp, running in Tomcat.
>> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
>> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

[jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12649555#action_12649555 ] 

Tim Moore commented on FELIX-827:
---------------------------------

The short answer is yes, if I set that property I don't get the error.

It's not a great workaround for us, however, because it means that the webapp doesn't get fully unloaded and so leaks memory every time it's redeployed. The use case we have is automated nightly deployment to a test server, so after a few days it will run out of permgen space and I'd rather not have to go in and restart Tomcat manually every so often. We also can't disable URLHandlers, since something somewhere in the app is using "bundle:" URLs.

I made a patch that seems to correct the problem at least for our case. It keeps track of the root URLHandlers instance separately from m_streamHandlerFactory variable. Then it always calls unregisterFrameworkListsForContextSearch on the root URLHandlers, either directly if it's in the same classloader, or through reflection otherwise.

I'll attach the patch to this issue. I haven't run into any problems with it yet, but I'm not sure it's 100% correct --- in fact, the more I think about it, I'm pretty sure it doesn't handle all possible cases correctly (e.g., if multiple webapps using Felix are deployed, then the first is removed).

I think that maybe a better implementation would have a chain of URLHandlers with the instance stored in URL.factory on one end, and on the other end an instance that delegates to whatever factory was installed before any Felix instances started. When a new Felix starts, it would swap itself with the delegate at the end of the chain, if any, and when an instance stops, it will replace itself with its delegate, either by setting its parent's delegate to its own, or if it's currently the root, replacing URL.factory with its delegate. What do you think? If you think this makes sense I can try to code it up and attach a new patch.

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls reassigned FELIX-827:
--------------------------------

    Assignee: Karl Pauls

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>         Attachments: test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652311#action_12652311 ] 

Karl Pauls commented on FELIX-827:
----------------------------------

Well, as I said, it is a different approach to (hopefully) resolving the issue then the one in your patch -- hence, try to unapply your patch first and see whether my patch makes a difference. 

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652219#action_12652219 ] 

Tim Moore commented on FELIX-827:
---------------------------------

Karl,

Thanks for your response. I'll test the patch. Unfortunately, the problem with memory leaks in webapps is rather bad, because class objects contain a reference to their classloader, and the classloader then contains references to every class that it loaded. So if even one class object reference leaks from a webapp classloader to a parent loader, the entire classloader cannot be collected. This makes it very important for anything in a webapp that registers itself with an object in the system classloader to unregister when the webapp is unloaded. These problems can be very tricky to track down, and until every single leak is patched, the problem will remain.

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Moore updated FELIX-827:
----------------------------

    Attachment: test-felix-handler.zip

Here's the source code for the test case. You can change the version of Felix it tests by editing the pom.xml dependency.

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>         Attachments: test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls updated FELIX-827:
-----------------------------

    Fix Version/s: felix-1.4.1
       Issue Type: Improvement  (was: Bug)

Yeah, what you see is the current state of the URLHandlers implementation. It would be nice if we would swap out our handler in all cases but currently, we only do that if no handler was set previously. In your second case, there was a handler set which we did swap out. As a consequence, we don't swap-out our handler but continue to delegate to the previous handler. 

I think our behaviour is not to bad. Problem is, somebody else (tomcat) is trying to do magic too. Together, the result is not what we want. We should look into swapping the previous handler back in. 

As a workaround, one could disable urlhandlers inside felix or (in case that is needed) try to set org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES to false. Could you let us know whether the later makes a difference?

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12658234#action_12658234 ] 

Tim Moore commented on FELIX-827:
---------------------------------

Karl,

Thanks for the fix. Sorry that I haven't been as responsive lately... I got caught up in other work and then the holidays.

We're still stuck on 1.2.1 (more specifically, a custom fork of it with a few backported fixes) due to some API changes in 1.4.x that we haven't had time to adapt to, but I'll try patching our version with your changes after the holidays and see if it helps.


> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Moore updated FELIX-827:
----------------------------

    Attachment: felix-827.patch

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Moore updated FELIX-827:
----------------------------

    Attachment: test-felix-handler-1.0-SNAPSHOT.jar

Here is a simple test case that demonstrates the problem. You should be able to run it by just running 'java -jar test-felix-handler-1.0-SNAPSHOT.jar'. It bundles Felix framework 1.4.0 and its transitive dependencies.

Here's the output I get:

tmoore@16:54:07$ java -jar target/test-felix-handler-1.0-SNAPSHOT.jar 
Initital URLStreamHandlerFactory: null
after starting Felix: org.apache.felix.framework.URLHandlers@d0220c
after stopping Felxi: null
after installing custom: com.atlassian.test.TestFelixHandler$1@ac5f13
after re-starting Felix: org.apache.felix.framework.URLHandlers@57ea52
after re-stopping Felix: org.apache.felix.framework.URLHandlers@57ea52


The last line, "after re-stopping Felix" should have restored the custom factory, "com.atlassian.test.TestFelixHandler$1@ac5f13"

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>         Attachments: test-felix-handler-1.0-SNAPSHOT.jar
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Tim Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652227#action_12652227 ] 

Tim Moore commented on FELIX-827:
---------------------------------

Karl,

I tried applying the patch to our custom build of felix-framework, but it didn't apply cleanly over my own patch. I'll keep watching in hopes that the underlying issue with URLHandlers is eventually resolved.

Thanks,
Tim

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls updated FELIX-827:
-----------------------------

    Attachment: leak.patch

This patch should release references to frameworks when they are stopped. It doesn't address the leak we have because we don't swap-out the first URLHandlers we set but that shouldn't be to much of a leak. Please let me know whether that makes a difference.

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls resolved FELIX-827.
------------------------------

    Resolution: Fixed

After looking at this issue and the provided patch again I did make it part of the bigger URLhandlers refactoring I did. Its commited to trunk now and will be part of the upcoming 1.4.1 release. It passes your testcase. 

Thanks again for reporting the issue and providing the patch. Please close this issue if it works for you. 

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, leak.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12649660#action_12649660 ] 

Karl Pauls commented on FELIX-827:
----------------------------------

Your last guess is correct, it wouldn't handle the "multiple classloaders that load URLHandlers" case correctly. That is the reason why I stopped at the current implementation (which does do what you suggest - at least sort of). I'm planning to revisit this and should have a fix before long. 

However, now that you mention it, are you sure the memory leak is due to the webapp not getting fully unloaded? The point is that we do leak framework instances inside the implementation and my guess would be that this is the reason why you see the run out of permgen space. That would be much easier to fix right now. In case I get this done, could you test it and see whether it fixes your issue? Then I would have more time to get the unloading and chaining case working correctly...

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>
>         Attachments: felix-827.patch, test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
>
>
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get errors, because Tomcat automatically sets the URLHandlers class's static members to null when it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.