You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Molina <mm...@csulb.edu> on 2007/04/22 21:52:42 UTC

NoClassDefFoundError - ApplicationContextAware

Last night I (unsuccessfully) attempted to set up a simple 
Struts 2 web app. I am absolutely sure that all the JAR 
files are in the correct /WEB-INF/lib directory.  The 
error appears to be happening because it cannot find the 
Spring interface ApplicationContextAware.  I would think 
that if Struts 2 had any dependencies on this interface, 
it would include them in its own JARs, and not require the 
user to go download the Spring framework during normal 
installation. I am using Eclipse 3.2, Tomcat v5.5, and 
have tried using both JDK 5 and 6.


Here is my struts.xml (I have also tried it using dummy 
action entries)

<!DOCTYPE struts PUBLIC
     "-//Apache Software Foundation//DTD Struts 
Configuration 2.0//EN"
     "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
</struts>



Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <display-name>StrutsTest</display-name>
     <filter>
         <filter-name>struts</filter-name>
         <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
     </filter>
     <filter-mapping>
         <filter-name>struts</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
…
</web-app>



Here is the stack trace:

SEVERE: Exception starting filter struts
Unable to load bean: 
type:com.opensymphony.xwork2.ObjectFactory 
class:org.apache.struts2.spring.StrutsSpringObjectFactory 
- bean - 
jar:file:/C:/tempworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/StrutsTest/WEB-INF/lib/struts2-spring-plugin-2.0.6.jar!/struts-plugin.xml:8:132
	at 
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:209)
	at 
org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
	at 
com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:131)
	at 
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
	at 
org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:398)
	at 
org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:455)
	at 
org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
	at 
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
	at 
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
	at 
org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
	at 
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
	at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
	at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at 
org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
	at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at 
org.apache.catalina.core.StandardService.start(StandardService.java:448)
	at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
	at 
org.apache.catalina.startup.Catalina.start(Catalina.java:552)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at 
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
	at 
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.NoClassDefFoundError: 
org/springframework/context/ApplicationContextAware
	at java.lang.ClassLoader.defineClass1(Native Method)
	at 
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at 
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1847)
	at 
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:873)
	at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1326)
	at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
	at 
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at 
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at 
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1847)
	at 
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:873)
	at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1326)
	at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
	at 
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:139)
	at 
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:181)
	... 24 more
Apr 22, 2007 12:30:03 PM 
org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart



Please help!

Sincerely,
Mike

P.S. The only help I could find on this problem is a post 
in another forum written in what I think is Mandarin 
Chinese:
http://www.blogjava.net/max/archive/2006/10/10/74353.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: NoClassDefFoundError - ApplicationContextAware

Posted by Martin Gainty <mg...@hotmail.com>.
yes ..it also comes in struts-plugin in struts2-showcase specifically
\struts2-showcase-2.0.6\WEB-INF\lib\struts2-spring-plugin-2.0.6.jar

M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Dave Newton" <ne...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Sunday, April 22, 2007 4:36 PM
Subject: Re: NoClassDefFoundError - ApplicationContextAware


> --- Mike Molina <mm...@csulb.edu> wrote:
>> The error appears to be happening because it cannot 
>> find the Spring interface ApplicationContextAware. 
> I
>> would think that if Struts 2 had any dependencies on
> 
>> this interface, it would include them in its own 
>> JARs, and not require the user to go download the 
>> Spring framework during normal installation.
> 
> If you are going to use Spring as your object factory
> then you will need to download Spring; S2 provides a
> *plugin* for Spring integration, but not Spring
> itself.
> 
> This makes sense if for no other reason than Spring is
> big, and you should be able to pick and choose which
> Spring components you want rather than create a
> dependency on the entire Spring distro.
> 
> S2 doesn't "depend" on Spring unless you tell it to
> (or, perhaps in this case, someone told it for you).
> 
> d.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: NoClassDefFoundError - ApplicationContextAware

Posted by Dave Newton <ne...@yahoo.com>.
--- Mike Molina <mm...@csulb.edu> wrote:
> The error appears to be happening because it cannot 
> find the Spring interface ApplicationContextAware. 
I
> would think that if Struts 2 had any dependencies on

> this interface, it would include them in its own 
> JARs, and not require the user to go download the 
> Spring framework during normal installation.

If you are going to use Spring as your object factory
then you will need to download Spring; S2 provides a
*plugin* for Spring integration, but not Spring
itself.

This makes sense if for no other reason than Spring is
big, and you should be able to pick and choose which
Spring components you want rather than create a
dependency on the entire Spring distro.

S2 doesn't "depend" on Spring unless you tell it to
(or, perhaps in this case, someone told it for you).

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org