| WAB context not finding local classes [message #739911] |
Mon, 17 October 2011 21:05  |
Mark Elliot Messages: 13 Registered: June 2011 |
Junior Member |
|
|
I'm running Virgo Jetty 3.0.1; my setup looks like this:
src/
com/foo/bar/
Baz.java
WebContent/
META-INF/
spring/
baz-context.xml
MANIFEST.MF
WEB-INF
web.xml
baz-context.xml contains (... is the xmlns stuff):
<beans ...>
<bean id="baz" class="com.foo.bar.Baz" />
</beans>
When I start this bundle I get an error:
Caused by: java.lang.ClassNotFoundException: com.foo.bar.Baz
My web.xml contains:
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Clearly Baz is a class. Strangely, if I move my spring config to the WEB-INF directory and set it up to be loaded by the servlet loader (using the web.xml stuff), the class is found and things come up just fine -- which leads me to believe the MANIFEST is correct and the actual class is getting included.
Why can't I initialize this class in the spring/ folder?
Supposing I can eventually initialize that bean with a config in the spring/ folder, can beans in servlet specific contexts reference items defined in those configs?
|
|
|
| Re: WAB context not finding local classes [message #740324 is a reply to message #739911] |
Tue, 18 October 2011 07:45   |
Chris Frost Messages: 222 Registered: January 2010 Location: Southampton, England |
Senior Member |

|
|
Hi,
You can either put all your spring context information in the applicationContext.xml file under WEB-INF and no config will be required in the web.xml or keep it in META-INF/spring and specify that as the location with 'contextConfigLocation' context-param.
Yes, servlet specific contexts will have full access to beans in your spring/osgi context, it will be one of its parent contexts due to the config you have put in web.xml as shown in your post.
As a side note, all the Manifest should need is the bundle classpath being set to include WEB-INF/classes where Baz.class should be compiled to.
Chris
------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
[Updated on: Tue, 18 October 2011 07:46] Report message to a moderator
|
|
|
| Re: WAB context not finding local classes [message #741509 is a reply to message #740324] |
Wed, 19 October 2011 11:45  |
Dmitry Sklyut Messages: 252 Registered: January 2010 |
Senior Member |
|
|
Quote:or keep it in META-INF/spring and specify that as the location with 'contextConfigLocation' context-param.
That would bring spring-dm extender into the picture. You want to keep spring context files out of META-INF/spring for web-apps and let org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext deploy them.
Regards,
Dmitry
|
|
|
Powered by
FUDForum. Page generated in 0.06932 seconds