Hey Rainer, Now the full answer :-)
On Sun, Aug 7, 2011 at 14:14, RainerW <[email protected]> wrote: > Got a running SpringDM with pax-wicket 0.7.2. > Great; Now that you don't have to relay on SpringDM for Wicket-OSGi integration (thanks to PW) Apache Aries for Blueprint, JPA and Transactions might also be valid options (but SpringDM is also OK and is planned to be supported for the next years in PW; so no problem). > BundleA exports a VotingService. BundleB (wicket) via a plain Service > can use that service -> so SpringDM works. > Great > In my OverviewPage (BundleB) i added an AjaxFallback Link which calls a > service-method. > > but when the services ping() method got called, a NPE occurs: > > java.lang.NullPointerException > at > > org.ops4j.pax.wicket.util.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:233) > at org.ops4j.pax.wicket.util.proxy.$Proxy17.ping(Unknown Source) > at de.bitnoise.konferenz.web.OverviewPage$1.onClick(OverviewPage.java:98) > at > > org.apache.wicket.ajax.markup.html.AjaxFallbackLink$1.onEvent(AjaxFallbackLink.java:73) > > > Where OverviewPage.java:98 is: > > String result = ref1.ping("call0"); > > where ref1 is : > > @PaxWicketBean > ExampleService ref1; > > ExampleService is actually a service inside the same bundle. But the > same error occurs with the VotingService from the other bundle. > > i'm a little bit confused by the Documentation: > http://team.ops4j.org/wiki/display/paxwicket/Injection+%28Quick%29 > > it say's : > "Injection is always local. Components in Bundle A can only receive > beans available in Bundle A's application context" > > Where some lines below : > > "As you might guess already it does not have to be a classic bean only > but could also be a <reference> or a <list> or any other named entity in > SpringDM or Blueprint." -> Which would be a not local bean!??? > Yeah, there is already a note to clarify that one. With local I mean the local ApplicationContext. As you've might noticed already spring (and also blueprint) create an ApplicationContext per bundle. You can inject each bean from this BundleContext, but only from this Bundle context. This is what I've meant with local. It doesn't mind here of which kind this bean is. > Anyway. The Bean in my case ( ExampleService ) is local + exported as > service, but it's still a local bean. > > At the moment i think pax-wicket doesn't know the correct Spring > context. Is there someway to register the Spring context? > 1) Why does this fail: PW works by delegating classloading and injection to the bundles responsible for those pages. This is done by proxies (that's the reason y you need to import the org.ops4j.pax.wicket.util.proxy and cglib packages). Those proxies are managed by various services. If you export any of the PW services the additional services for mount-points, injection and classloading are registered automatically. If your bundle does not export any of the PW services (application, page, ...) you have to register them manualy. 2) Why is this not documented This is the problem with a wiki documentation. You can't really version it. PW 0.7 to PW 0.8 contains a big amount of new features and various API changes to support Wicket 1.4 AND 1.5 side by side. While most of those API changes won't affect you the documentation is affected at a wide range of places. PW 0.8 will be finished within this month so I don't hope that I have to keep those differences up for long. Feel free to answer for any problem (as you already do :-)) and I'll try to answer as detailed and fast as possible. For PW 0.8 you wont need to register those services manually any longer. PW 0.8 comes with an BundleListener analysing each bundle for org.apache.wicket imports. Once it find those it will automatically register delegation services for your bundle freeing you of the burden to register them manually. 3) How does this look like for PW 0.7.x For PW 0.7 you have to register those services as shown in [1]. If you do not want to use the wicket namespace for this task feel free to ask. Of cause there are other ways too to register those services. This service handles the classloading of your (possible internal) wicket classes and is absolutely necessary. <wicket:classResolver id="classResolver" applicationName="openengsb" /> This one is only required in case you like to use the @PaxWicketBean annotation <wicket:injectionProvider id="injectionProvider" applicationName="openengsb" /> This one is only required if you like to use the @MountPoint annotation <wicket:autoPageMounter id="autoPageMounter" applicationName="openengsb" /> I hope that this solves your problem and helps to get PW up and running. Feel free to poke me again in case of any other problem! Kind regards, Andreas [1] https://github.com/openengsb/openengsb/blob/master/ui/common/src/main/resources/META-INF/spring/wicket-context.xml > PS: > For completeness, there is no BundelActivator. I use a Spring > postConstruct to register the wicket app: > > @PostConstruct > public void init() > { > System.out.println("##### Start " + bc); > String mountPoint = "deptStore"; > String applicationName = "departmentstore"; > store = new RootContentAggregator(bc, applicationName, "swp"); > store.register(); > > overviewPageFactory = new OverviewPageFactory(bc, store, > applicationName, > "overview"); > overviewPageFactory.register(); > > PaxWicketApplicationFactory applicationFactory = new > PaxWicketApplicationFactory( > bc, OverviewPage.class, mountPoint, applicationName); > > // This registers the pax-wicket service as OSGi Service. > serviceRegistration = applicationFactory.register(); > System.out.println("##### DONE"); > } > > > create via : > > <beans:bean class="de.bitnoise.konferenz.web.internal.MyAppFactory" > init-method="init"/> > > > Cheers Rainer > > > _______________________________________________ > general mailing list > [email protected] > http://lists.ops4j.org/mailman/listinfo/general >
_______________________________________________ general mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/general
