You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Johan Huylebroeck (JIRA)" <ji...@apache.org> on 2012/07/31 12:42:35 UTC

[jira] [Created] (ARIES-894) Using blueprintBundle as a factory bean for resources throws IllegalAccessException

Johan Huylebroeck created ARIES-894:
---------------------------------------

             Summary: Using blueprintBundle as a factory bean for resources throws IllegalAccessException
                 Key: ARIES-894
                 URL: https://issues.apache.org/jira/browse/ARIES-894
             Project: Aries
          Issue Type: Bug
          Components: Blueprint
    Affects Versions: blueprint-0.3.1
            Reporter: Johan Huylebroeck


I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 

<bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
       <argument value="scripts/myScript"/>
</bean>

But it fails with this exception:

java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"

                at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]

                at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]

                at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]

                at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]

                at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]

                ... 15 more


The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.

There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.


--
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] (ARIES-894) Using blueprintBundle as a factory bean for resources throws IllegalAccessException

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

Johan Huylebroeck updated ARIES-894:
------------------------------------

    Attachment: aries-894.patch.gz

My bad, seems I managed to mess up the arguments to git diff.
I attached the patch again (with all the changes this time)
Missing test are in MethodResolverTest

                
> Using blueprintBundle as a factory bean for resources throws IllegalAccessException
> -----------------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>         Attachments: aries-894.patch.gz, aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Unable to access public methods overriden/implemented in a protected class

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ARIES-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13426364#comment-13426364 ] 

Guillaume Nodet commented on ARIES-894:
---------------------------------------

Improve perfs with http://svn.apache.org/viewvc?rev=1367686&view=rev
                
> Unable to access public methods overriden/implemented in a protected class
> --------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>             Fix For: blueprint-core-1.0.1
>
>         Attachments: aries-894.patch.gz, aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Using blueprintBundle as a factory bean for resources throws IllegalAccessException

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

Johan Huylebroeck updated ARIES-894:
------------------------------------

    Attachment: aries-894.patch.gz

created a patch against the latest aries trunk on github of blueprint-core. Moved some code from BeanRecipe to separate classes (MethodResolver, ...). Test were moved/added accordingly.
                
> Using blueprintBundle as a factory bean for resources throws IllegalAccessException
> -----------------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>              Labels: patch
>         Attachments: aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Unable to access public methods overriden/implemented in a protected class

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

Guillaume Nodet resolved ARIES-894.
-----------------------------------

    Resolution: Fixed

Fixed in http://svn.apache.org/viewvc?rev=1367681&view=rev
                
> Unable to access public methods overriden/implemented in a protected class
> --------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>             Fix For: blueprint-core-1.0.1
>
>         Attachments: aries-894.patch.gz, aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Unable to access public methods overriden/implemented in a protected class

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

Guillaume Nodet updated ARIES-894:
----------------------------------

    Fix Version/s: blueprint-core-1.0.1
          Summary: Unable to access public methods overriden/implemented in a protected class  (was: Using blueprintBundle as a factory bean for resources throws IllegalAccessException)
    
> Unable to access public methods overriden/implemented in a protected class
> --------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>             Fix For: blueprint-core-1.0.1
>
>         Attachments: aries-894.patch.gz, aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Using blueprintBundle as a factory bean for resources throws IllegalAccessException

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

Guillaume Nodet reassigned ARIES-894:
-------------------------------------

    Assignee: Guillaume Nodet
    
> Using blueprintBundle as a factory bean for resources throws IllegalAccessException
> -----------------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>         Attachments: aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Using blueprintBundle as a factory bean for resources throws IllegalAccessException

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ARIES-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13425888#comment-13425888 ] 

Guillaume Nodet commented on ARIES-894:
---------------------------------------

I think the patch is wrong in the way it's fixing the problem.
The main reason is that the exact same problem happen with setters and lifecycle methods.
I'm tempted to use a setAccessible(true) call before invoking any public method to cope with class visibility.
Another way would be to reuse the same mechanism you provided in the patch but in a more generic way, i.e. rewrite a helper method to execute Class.getMethods() but in a smarter way.
The problem is that Class.getMethods() does the opposite, i.e. it hides all super methods if those are redefined in the base class.

I'm investigating further...
                
> Using blueprintBundle as a factory bean for resources throws IllegalAccessException
> -----------------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>         Attachments: aries-894.patch.gz, aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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] (ARIES-894) Using blueprintBundle as a factory bean for resources throws IllegalAccessException

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ARIES-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13425702#comment-13425702 ] 

Guillaume Nodet commented on ARIES-894:
---------------------------------------

I think there is a missing test case, because the A, B, C and Factory classes aren't used anywhere.
And I'd rather split the refactoring from the real bug fix, it makes things much easier to review and keep history cleaner for later reviewal.
                
> Using blueprintBundle as a factory bean for resources throws IllegalAccessException
> -----------------------------------------------------------------------------------
>
>                 Key: ARIES-894
>                 URL: https://issues.apache.org/jira/browse/ARIES-894
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-0.3.1
>            Reporter: Johan Huylebroeck
>            Assignee: Guillaume Nodet
>              Labels: patch
>         Attachments: aries-894.patch.gz
>
>
> I’m using apache aries 0.3.2 and I was trying to lookup a script in the bundle like this: 
> <bean id="script" factory-ref="blueprintBundle" factory-method="getEntry">
>        <argument value="scripts/myScript"/>
> </bean>
> But it fails with this exception:
> java.lang.IllegalAccessException: Class org.apache.aries.blueprint.utils.ReflectionUtils can not access a member of class org.apache.felix.framework.BundleImpl with modifiers "public"
>                 at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)[:1.6.0_32]
>                 at java.lang.reflect.Method.invoke(Method.java:588)[:1.6.0_32]
>                 at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)[10:org.apache.aries.blueprint:0.3.2]
>                 at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:236)[10:org.apache.aries.blueprint:0.3.2]
>                 ... 15 more
> The problem seems to be that the factory method is resolved against the implementation class BundleImpl which is package private and not the interface org.osgi.framework.Bundle which is public.
> There is a workaround by injecting the bundle in a wrapper bean and using this bean to do the lookup.

--
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