You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Brian Stansberry (Created) (JIRA)" <ji...@apache.org> on 2012/01/06 00:03:39 UTC

[jira] [Created] (FELIX-3296) URLHandlers caches null as values for common protocols

URLHandlers caches null as values for common protocols
------------------------------------------------------

                 Key: FELIX-3296
                 URL: https://issues.apache.org/jira/browse/FELIX-3296
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: framework-3.0.8
         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
            Reporter: Brian Stansberry


A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]

Here's the problem. Line references are to [2]:

1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".

2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.

3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".

4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).

A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).

An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.

[1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
[2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls commented on FELIX-3296:
-----------------------------------

I'll try to have a look tonight.
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls resolved FELIX-3296.
-------------------------------

    Resolution: Fixed

I applied the patch. Please close if it works for you.
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296-2.patch, FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls commented on FELIX-3296:
-----------------------------------

Yes, I agree - this is a bug. Thanks for reporting - I'll try to get to it asap.
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls commented on FELIX-3296:
-----------------------------------

Thanks, Felix. That looks good now - I'll give it some more looking at and try to work in the other outstanding URLHandlers issues but i expect to commit something tonight.
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296-2.patch, FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Richard S. Hall updated FELIX-3296:
-----------------------------------

    Fix Version/s: framework-4.2.0
    
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Felix Meschberger updated FELIX-3296:
-------------------------------------

    Attachment: FELIX-3296-2.patch

Extended patch:
  + in the init() method ensure the handler found is used to create the URL
  + synchronize initialization on URL.class since we fiddle with the factory field

This supercedes (and includes) the previous patch
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296-2.patch, FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Felix Meschberger commented on FELIX-3296:
------------------------------------------

> The idea is that if there is a previous urlhandlersfactory, we should delegate to that one. If it
> isn't doing that, there is a bug in there. Caching the null value is what should happen.

Event the platform is not expecting the URLStreamHandlerFactory to be "complete". If the factory does not return anything, it checks with its known handler classes (see URL.getURLStreamHandler(String); at least in the Sun VM).

> Caching the null value is what should happen

That's still happening, if there is a null situation after all.

> Thing is, somebody on the outside doesn't want us to see the classes, so we shouldn't try to get them from some place else

Agreed. But then that somebody (URLStreamHandlerFactory) should provide the handlers. Particularly the jar: handler but probably also the other ones, at least http: and https: would be helpful.

> but the URLHandlers are a very tricky hack to begin with so lets see whether there is a different way. 

I'd love to have a better solution ;-)

> Am I correct in saying that jboss installs its own urlhandlersfactory which will give us the required protocols? 

It installs, but does not give the missing handlers, which is why I did that trickery.

BTW: The patch implements exactly the three steps: trying the factory, falling back to known packages in framework class loader, falling back to known packages in system class loader.
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Robert Munteanu commented on FELIX-3296:
----------------------------------------

In reply to comment #1:
> Yes, I agree - this is a bug. Thanks for reporting - I'll try to get to it asap.

Karl, did you manage to look into this? I'm willing to test any patches if needed.
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls reassigned FELIX-3296:
---------------------------------

    Assignee: Karl Pauls
    
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls commented on FELIX-3296:
-----------------------------------

Regarding your patch so, I think there are some issues with it - can we discuss it via skype?
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

Posted by "Thomas Diesler (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13182719#comment-13182719 ] 

Thomas Diesler commented on FELIX-3296:
---------------------------------------

Related to [AS7-3228|https://issues.jboss.org/browse/AS7-3228]
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls commented on FELIX-3296:
-----------------------------------

Well, after looking at a bit more, I'm not so sure what the correct solution is. First, I disagree with the proposed fix in the description. The idea is that if there is a previous urlhandlersfactory, we should delegate to that one. If it isn't doing that, there is a bug in there. Caching the null value is what should happen.

Regarding the patch of Felix Meschberger: I see the problem however, I'm not sure it is a correct solution to default to the system classloader. Thing is, somebody on the outside doesn't want us to see the classes, so we shouldn't try to get them from some place else. Granted, if that is the only work to make this work we might have to but the URLHandlers are a very tricky hack to begin with so lets see whether there is a different way. 

Am I correct in saying that jboss installs its own urlhandlersfactory which will give us the required protocols?
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (FELIX-3296) URLHandlers caches null as values for common protocols

Posted by "Thomas Diesler (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13182719#comment-13182719 ] 

Thomas Diesler edited comment on FELIX-3296 at 1/9/12 7:13 PM:
---------------------------------------------------------------

Related to https://issues.jboss.org/browse/AS7-3228
                
      was (Author: tdiesler):
    Related to [AS7-3228|https://issues.jboss.org/browse/AS7-3228]
                  
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Richard S. Hall updated FELIX-3296:
-----------------------------------

    Fix Version/s:     (was: framework-4.2.0)
                   framework-4.0.3
    
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.0.3
>
>         Attachments: FELIX-3296-2.patch, FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Felix Meschberger updated FELIX-3296:
-------------------------------------

    Attachment: FELIX-3296.patch

Proposed patch:

Instead of just trying to load the well-known default handlers we have to play some tricks. The patch changes the setup as follows to load each pre-defined scheme:

  1. try installed URLStreamHandlerFactory if any
  2. try loading well-known handler class through framework class loader
  3. try loading well-known handler class through system class loader (ClassLoader.getSystemClassLoader())

The first step IMHO makes sense if the pre-installed factory would overwrite any well-known handler (for example the file: handler from JBoss). The last step is to circumvent the JBoss ModuleClassLoader, which effectively hides the Java Platform classes (as OSGi does).
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3296) URLHandlers caches null as values for common protocols

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

Karl Pauls commented on FELIX-3296:
-----------------------------------

> Event the platform is not expecting the URLStreamHandlerFactory to be "complete". If the factory does not return anything, it checks with its known handler classes (see URL.getURLStreamHandler(String); at least in the Sun > VM). 

And that is our problem. We can't get the handlers from anywhere proper but we have to get them. That is the overal story of the urlhandlers, we have to fight the system every turn just to get them to work :-(

>> Caching the null value is what should happen

> That's still happening, if there is a null situation after all. 

Right, that wasn't in regard to your patch but in regard to the original proposal.

>> but the URLHandlers are a very tricky hack to begin with so lets see whether there is a different way.

> I'd love to have a better solution ;-) 

Me too :-)

but as I said, we might have to resort to your patch. As of now, i can only think of stuff that is even worse :-D
                
> URLHandlers caches null as values for common protocols
> ------------------------------------------------------
>
>                 Key: FELIX-3296
>                 URL: https://issues.apache.org/jira/browse/FELIX-3296
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-3.0.8
>         Environment: Apache Sling 	org.apache.sling.launchpad-6.war running in build of current master branch of JBoss Application Server 7 (https://github.com/jbossas/jboss-as). I'm reporting this against framework-3.0.8 as that seems to be what's included in Sling, but a review of the code in 4.0.2 shows the class is the same.
>            Reporter: Brian Stansberry
>            Assignee: Karl Pauls
>             Fix For: framework-4.2.0
>
>         Attachments: FELIX-3296.patch
>
>
> A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]
> Here's the problem. Line references are to [2]:
> 1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".
> 2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.
> 3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".
> 4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).
> A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).
> An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.
> [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
> [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira