OSGI reference Bean not found [message #717124] |
Fri, 19 August 2011 11:31 |
Peter Mucha Messages: 6 Registered: August 2011 |
Junior Member |
|
|
Hi,
I have the following setup:
one WAB, containing a @Controller, which has an attribute @Autowired at a private porperty of interfacetype X
import of osgi-service via <osgi:reference interface="X" id="sid" />
Another Bundle (not web-specific) defining interface X and an implementation
Ximpl (anotated with @Controller("ximpl")).
export of this service via <osgi:service interface="X" ref="ximpl" />
from the virgo admin panel, it looks fine concerning as exporting and importing of service.
under consumed services of the WAB, it says:
org.springframework.osgi.bean.name ximpl
service.id 265
Bundle-SymbolicName HelperBundle
objectClass org.helper.X
Bundle-Version 1.0.0
which means, that the export and import worked.
additionally, there is one Bean in the spring context:
sid $Proxy173 false true
which means, a bean with the name sid (as given in the osgi:reference-tag) exists
now, the final step fails:
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private [...] nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.helper.X]
can someone hopefully point me to my error?
or is it a bug?
thanks, peter
[Updated on: Fri, 19 August 2011 11:33] Report message to a moderator
|
|
|
Re: OSGI reference Bean not found [message #717213 is a reply to message #717124] |
Fri, 19 August 2011 15:48 |
Peter Mucha Messages: 6 Registered: August 2011 |
Junior Member |
|
|
After some more work on this problem, i have a related question:
i have the following setup in the WAB project:
in META-INF/spring/osgi-context.xml, i define the osgi:reference-bean
in WEB-INF/spring/blabla-context.xml, i define the annotation processing for my @Controller.
could it be, that there are separate contexts in which the beans reside? so that the @Controller cannot find my bean, declared in osgi-context.xml?
i tried to reference the osgi-service in the blabla-context.xml, but virgo (or more specifically, spring) throw me this error:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'osgi:reference'.
so it seems to be the only option to reference osgi-xml-namespace in the meta-inf-directory, which sounds kind of weird to me.
am i still on the right way?
|
|
|
Re: OSGI reference Bean not found [message #717246 is a reply to message #717213] |
Fri, 19 August 2011 17:34 |
Dmitry Sklyut Messages: 279 Registered: January 2010 |
Senior Member |
|
|
Peter,
One thing that jumps out is the location of osgi-context.xml in WAB project. Because it sits in /META-INF/spring it might be getting picked up by Spring-osgi extender bundle - that is not what you want. You want that config to be picked up by the ServerOsgiBundleXmlWebApplicationContext in web.xml
example
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/context/applicationContext-osgi.xml
/WEB-INF/spring/context/applicationContext.xml
</param-value>
</context-param>
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
With this modification you will also need an Import-Package: org.eclipse.virgo.web.dm
If this does not solve your problem, would you mind providing:
1. Your web.xml for WAB project
2. Manifest for WAB project
3. Manifest for Helper project.
This will help in figuring out the details.
Thanks
Dmitry
[Updated on: Fri, 19 August 2011 17:35] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03499 seconds