Hi Raffaele, The Spring framework expects to be able to find all of the beans from a single class loader, which is often the source of problems. It gets even worse in many cases, because the Spring modules try to use their own class loader which can’t see any of the types at all.
Depending on how deeply your application depends on Spring there are a number of things that you could do. The simplest and most flexible dependency injection in OSGi is provided by a specification called Declarative Services. This would allow you to inject instances of your “beans” into other OSGi components. This, however, could be quite a change from your existing application wiring model if Spring is heavily used. Another OSGi specification, called the Blueprint Container, is much more similar to Spring (effectively being a standardised version of Spring DM). This has a similar model to what you’re currently using, but probably won’t support more advanced Spring features if you’re using them. Personally, I would look hard at using Declarative Services and the Http Whiteboard to decompose the applications, but your mileage may vary. Regards, Tim Ward OSGi IoT Expert Group Chair tim.w...@paremus.com > On 19 Jul 2017, at 10:52, Raffaele Gambelli > <r.gambe...@hitachi-systems-cbt.com> wrote: > > Sorry, I submit again the same question because in the previous one I forgot > the subject > > Hi all, this is my first question in this list. > > I'm trying to adjust a quite complex system, made with OSGI but which was > made quite badly, in addition I have to say that I have no so much experience > with OSGI. > > Briefly, I have four webapps on jetty which should live inside the same > Equinox runtime, till today they and their needed bundles have been deployed > in a such a way that quite all bundles embedded all their dependencies, so > there is a huge confusion.... while I'm hardly working to create very smaller > bundles, emptying them from the embedded dependencies and making them work > together in what I believe be the OSGI paradygm. > > Just to let you know some other elements helping to understand my problems > and knowledge here it is a question posted some weeks ago > https://stackoverflow.com/questions/44897956/deploy-webapp-in-jetty-in-osgi > where a very kind person exhaustively answered. > > Now i explain my current problem, I'm finally arrived to have a running > webapplication, but as soon as it accesses Spring bean, it is not found, so > for example I have a NPE in a row like this: > > SessionDao sessionDao = (SessionDao) > SpringContextProvider.getApplicationContext().getBean("sessionDao"); > > That bean is configured in a different bundle and for what I'm undestanding > that is the matter, so after some research I arrived to "Spring Dynamic > Modules", so I'm reading this > http://docs.spring.io/osgi/docs/current/reference/html-single/#why-Spring DM > > so my question is, am I on the right path? Should I go deeply with Spring DM > to configure bean in bundle A and make it available on bundle B? > > Thanks very much, bye > > Raffaele Gambelli > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev