The weaving hook performs the weave at class load time. The weaving hook 
is registered when the org.apache.aries.proxy bundle starts. If your 
org.restlet.Application class has already been loaded by the time the hook 
is registered then it will be too late for the weaving hook to see the 
load and weave the class. You could try installing and starting the proxy 
bundle before your org.restlet bundle (or wherever your Application class 
comes from) to see if that is the problem. Personally I use bundle start 
levels to ensure that the weaving hook is registered before any of the 
bundles that I expect to get woven, but I'm sure it can be done in other 
ways as well e.g. service dependencies.

Rich



From:   Roger Stocker <[email protected]>
To:     [email protected], 
Date:   16/08/2013 13:06
Subject:        Re: Problem with service-reference with 
proxy-method="classes"



Tom, thank you!

To my view, I have all conditions met. Look at my bundles:

g! ss
"Framework is launched."


id    State       Bundle
0    ACTIVE      org.eclipse.osgi_3.8.1.v20120830-144521
64    RESOLVED    org.code4you.log4j.config_1.0.0
                Master=167
82    ACTIVE      org.code4you.osgi.org.slf4j.jul2slf4j.activator_1.0.0
103    ACTIVE      org.code4you.blueprint.test_1.0.0
144    ACTIVE      org.code4you.osgi.manager_1.0.0
146    ACTIVE      org.apache.aries.util_1.0.0
147    ACTIVE      org.restlet_2.1.2.v20130228-2152
148    ACTIVE      org.apache.aries.blueprint_1.1.0
149    ACTIVE      org.apache.felix.gogo.command_0.12.0
150    ACTIVE      org.eclipse.equinox.console_1.0.0.v20120522-1841
151    ACTIVE      org.apache.xbean.bundleutils_3.14.0
152    ACTIVE      org.apache.aries.proxy_1.0.0
153    ACTIVE      org.objectweb.asm_4.1.0
154    ACTIVE      com.springsource.slf4j.org.apache.commons.logging_1.6.1
155    ACTIVE      org.apache.aries.blueprint.annotation.api_1.0.0
156    ACTIVE      com.springsource.slf4j.api_1.6.1
                Fragments=164
157    ACTIVE      org.objectweb.asm.tree_4.1.0
158    ACTIVE      com.springsource.slf4j.bridge_1.6.1
159    ACTIVE      org.apache.felix.gogo.shell_0.10.0
160    ACTIVE      org.apache.felix.gogo.runtime_0.10.0
161    ACTIVE      org.apache.aries.blueprint.annotation.impl_1.0.0
162    ACTIVE      org.eclipse.osgi.services_3.2.100.v20100503
163    ACTIVE      org.apache.xbean.finder_3.14.0
164    RESOLVED    com.springsource.slf4j.log4j_1.6.1
                Master=156
165    ACTIVE      org.objectweb.asm.commons_4.1.0
166    ACTIVE      org.apache.xbean.reflect_3.14.0
167    ACTIVE      com.springsource.org.apache.log4j_1.2.16
                Fragments=64

And I didn't disable weaving. Am I missing something?

Thanks
Roger


On 16.08.13 12:50, Richard Ellis wrote:
The Apache Aries subclass proxy generates a subclass at runtime to be able 
to proxy a class. This has the limitation of not being able to work on 
final classes or final methods. The newer Apache Aries weaving based proxy 
is able to generate proxies for these types of classes. The weaving proxy 
is enabled by default if you are using an environment where OSGi weaving 
hooks are supported (spec level 4.3 or higher). If weaving hooks aren't 
supported or weaving has been disabled then the proxy will fall back to 
sub-classing. 

Rich 



From:        Roger Stocker <[email protected]> 
To:        [email protected], 
Date:        16/08/2013 11:31 
Subject:        Problem with service-reference with proxy-method="classes" 




I try to track a list of services. Here is the definition:
    <reference-list id="applicationServices" 
interface="org.restlet.Application" ext:proxy-method="classes">
        <reference-listener bind-method="onApplicationRegistered" 
unbind-method="onApplicationUnregistered" ref="virtualHostListener"/>
    </reference-list>

The org.restlet.Application is a class and therefore I put 
ext:proxy-method="classes" to the reference. All dependencies to 
objectweb-asm are satisfied and org.apache.aries.proxy is bound to it.

Now I get this stacktrace:
org.apache.aries.proxy.FinalModifierException: The methods public final 
void 
org.restlet.Restlet.handle(org.restlet.Request,org.restlet.Uniform), 
public final org.restlet.Response 
org.restlet.Restlet.handle(org.restlet.Request), public final void 
org.restlet.Restlet.handle(org.restlet.Request,org.restlet.Response,org.restlet.Uniform)
 

in class org.restlet.Application are final.
    at 
org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.getProxySubclass(ProxySubclassGenerator.java:106)
    at 
org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.newProxySubclassInstance(ProxySubclassGenerator.java:159)
    at 
org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:103)
    at 
org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingInterceptingProxy(AbstractProxyManager.java:75)
    at 
org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingProxy(AbstractProxyManager.java:40)
    at 
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.createProxy(AbstractServiceReferenceRecipe.java:306)
    at 
org.apache.aries.blueprint.container.ReferenceListRecipe.track(ReferenceListRecipe.java:124)
    at 
org.apache.aries.blueprint.container.ReferenceListRecipe.retrack(ReferenceListRecipe.java:89)
    at 
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.updateListeners(AbstractServiceReferenceRecipe.java:422)
    at 
org.apache.aries.blueprint.container.ReferenceListRecipe.internalCreate(ReferenceListRecipe.java:75)
    at 
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at 
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
    at 
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
    at 
org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
    at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
    at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
    at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
    at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at 
org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
    at 
org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
    at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

Does that mean, that I cannot use org.restlet.Application as the 
referenced interface?
Any workaround?

The same thing works with the Gemini Blueprint-Extender 
(spring-extender). Why? Is it because the spring-extender uses another 
bytecode weaving library (cglib)?







Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU 













Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU





Reply via email to