Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » WAB context not finding local classes
WAB context not finding local classes [message #739911] Tue, 18 October 2011 01:05 Go to next message
Mark Elliot is currently offline Mark ElliotFriend
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 11:45 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
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 11: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 15:45 Go to previous message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
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
Previous Topic:JavaOne
Next Topic:problems upgrading from 2.1.1 to 3.0.1
Goto Forum:
  


Current Time: Tue Apr 16 22:28:12 GMT 2024

Powered by FUDForum. Page generated in 4.39450 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top