You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Daniele Dellafiore <da...@dellafiore.net> on 2011/04/06 14:45:26 UTC

Re: spring-osgi and autowired

On Wed, Mar 30, 2011 at 6:57 PM, Allen Lau <al...@gmail.com> wrote:

> I think what you want to do is achievable if you have some custom code to
> search through all the bundles imported and get the springA.xml and add it
> to your application context.
>
> I see that you are using Spring-DM, so in that case, if you are relying on
> the extender, why not expose your bundle A beans as services and then
> reference them from bundle B,C,D, etc.
>

I'd like to to that but what I need is that service exported from bundle B
are a single instance container-wide, while I need a different instance to
work for each bundle that import that beans.

So the first solution is the best: some code to load the beans from a
imported bundle.
I can export those as service only if I can have a new instance for every
application bundle that uses my library bundle beans. Is this possible?



>
>
> On Wed, Mar 30, 2011 at 5:37 AM, Daniele Dellafiore
> <da...@dellafiore.net>wrote:
>
> > On Wed, Mar 30, 2011 at 2:23 PM, Daniele Dellafiore
> > <da...@dellafiore.net>wrote:
> >
> > > Hi have bundle A with a springA.xml file that depends on beans from
> > bundle
> > > B springB.xml
> > > I've added a springA-osgi.xml with declared services and on bundle A
> > > activation everything works and I have
> > >
> > >
> > > | INFO  | tenderThread-114 | OsgiServiceFactoryBean           |
> > > r.support.OsgiServiceFactoryBean  301 | 42 -
> > org.springframework.osgi.core -
> > > 1.2.0 | Publishing service under classes
> > > [{in.laz.storage.mongo.StorageTemplate}]
> > > INFO  | tenderThread-114 | OsgiServiceFactoryBean           |
> > > r.support.OsgiServiceFactoryBean  301 | 42 -
> > org.springframework.osgi.core -
> > > 1.2.0 | Publishing service under classes [{com.mongodb.Mongo}]
> > >
> > > both of them (even if I really need to export the first as service,
> being
> > > the second injected in the first, anyway.
> > >
> > > Then bundleB have a StorageTemplate (first service) autowired into a
> > bean.
> > > That does not work:
> > > "No matching bean of type [in.laz.storage.mongo.StorageTemplate] found
> > for
> > > dependency"
> > >
> > > even if in springB,xml I import both springA and springA-osgi xml
> (which
> > I
> > > thiink should not be necessary).
> > >
> > > Two question here:
> > > 1. What am I possibly missing that's not making it work?
> > > 2. I'd like that every bundle that imports springA.xml create some new
> > > instances of the beans defined there, but I do not think that's what is
> > > happening: I thing that bundle A instance the beans and export them as
> > > services, and the same instance is eventually injected into the beans
> of
> > > bundle B. That's not what I want, I just want the spring beans
> definition
> > to
> > > stay in bundle A so I do not have to duplicate it in every other
> bundle,
> > how
> > > can I achieve that?
> > >
> >
> > sorry I sent it before was completed.
> > So basically I am failing doing a thing that's not what i really need to
> > do,
> > I just realised :)
> >
> > But I am not finding a way to just make a bundle read xml files from
> other
> > bundles, that should be supported, isn't it? I expect it to be even
> easier
> > than autowiring spring beans exported as osgi services, but if xml are
> not
> > exported... that won't work at all.
> >
> > Thanks for any hint.
> >
>

RE: webconsole and servlet api bundle versions

Posted by ad...@bt.com.
OK, so I think I have resolved this particular problem by removing the version information from the 

		map.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "com.bt.test;version=1.0.0,javax.servlet,javax.servlet.http;version=2.5");

in my host application to make it:

		map.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "com.bt.test;version=1.0.0,javax.servlet,javax.servlet.http");

Mind you, still can't get my bridge to work, just getting ServiceUnavailable. Will investigate further.....



-----Original Message-----
From: adrian.p.smith@bt.com [mailto:adrian.p.smith@bt.com] 
Sent: 06 April 2011 17:21
To: users@felix.apache.org
Subject: webconsole and servlet api bundle versions

Hello all,

I'm trying to deploy the latest version of webconsole (3.1.8) into my embedded felix application and I am struggling with the version of servlet api needed.

1. I have tried not supplying any additional bundles and relying on the Serlvet container (jetty) that has a 2.5 version:

ERROR: Bundle org.apache.felix.webconsole [4] Error starting file:/home/adrian/work/jetty-6.1.15/bundle/org.apache.felix.webconsole-3.1.8.jar (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.webconsole [4].)
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) previously initiated loading for a different type with name "javax/servlet/ServletConfig"
	at java.lang.ClassLoader.defineClass1(Native Method)




2. I have tried using com.springsource.javax.servlet-2.5.0.jar. This appears to load ok, but when I try and access the console from my browser I see:

2011-04-06 17:18:50.114::WARN:  Error for /felix/system/console
java.lang.LinkageError: loader constraint violation: when resolving method "javax.servlet.ServletRequestEvent.<init>(Ljavax/servlet/ServletContext;Ljavax/servlet/ServletRequest;)V" the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) of the current class, org/apache/felix/http/base/internal/DispatcherServlet, and the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) for resolved class, javax/servlet/ServletRequestEvent, have different Class objects for the type javax/servlet/ServletContext used in the signature
	at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:62)

3. Using com.springsource.javax.servlet-2.4.0.jar gives:

ERROR: Bundle org.apache.felix.webconsole [5] Error starting file:/home/adrian/work/jetty-6.1.15/bundle/org.apache.felix.webconsole-3.1.8.jar (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.webconsole [5].)
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) previously initiated loading for a different type with name "javax/servlet/ServletConfig"
	at java.lang.ClassLoader.defineClass1(Native Method)

Any help appreciated.

Thanks

Adrian Smith


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


webconsole and servlet api bundle versions

Posted by ad...@bt.com.
Hello all,

I'm trying to deploy the latest version of webconsole (3.1.8) into my embedded felix application and I am struggling with the version of servlet api needed.

1. I have tried not supplying any additional bundles and relying on the Serlvet container (jetty) that has a 2.5 version:

ERROR: Bundle org.apache.felix.webconsole [4] Error starting file:/home/adrian/work/jetty-6.1.15/bundle/org.apache.felix.webconsole-3.1.8.jar (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.webconsole [4].)
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) previously initiated loading for a different type with name "javax/servlet/ServletConfig"
	at java.lang.ClassLoader.defineClass1(Native Method)




2. I have tried using com.springsource.javax.servlet-2.5.0.jar. This appears to load ok, but when I try and access the console from my browser I see:

2011-04-06 17:18:50.114::WARN:  Error for /felix/system/console
java.lang.LinkageError: loader constraint violation: when resolving method "javax.servlet.ServletRequestEvent.<init>(Ljavax/servlet/ServletContext;Ljavax/servlet/ServletRequest;)V" the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) of the current class, org/apache/felix/http/base/internal/DispatcherServlet, and the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) for resolved class, javax/servlet/ServletRequestEvent, have different Class objects for the type javax/servlet/ServletContext used in the signature
	at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:62)

3. Using com.springsource.javax.servlet-2.4.0.jar gives:

ERROR: Bundle org.apache.felix.webconsole [5] Error starting file:/home/adrian/work/jetty-6.1.15/bundle/org.apache.felix.webconsole-3.1.8.jar (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.webconsole [5].)
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) previously initiated loading for a different type with name "javax/servlet/ServletConfig"
	at java.lang.ClassLoader.defineClass1(Native Method)

Any help appreciated.

Thanks

Adrian Smith


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org