File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes NoClassDefFoundError: org/springframework/context/ApplicationContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "NoClassDefFoundError: org/springframework/context/ApplicationContext" Watch "NoClassDefFoundError: org/springframework/context/ApplicationContext" New topic

NoClassDefFoundError: org/springframework/context/ApplicationContext

Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53

I have just started working on springs and have done my first "Hello World" example. It is working fine - one place that i am getting stuck with is do i need to set the spring.jar and related jar's in my classpath in order to execute it from the command line?

The sample program works fine in Eclipse - but now i have made a jar and want to execute it from the command line and i am getting the following error - i tried to set the springs.jar to the classpath but its not working - what am i missing - [this is bugging ]

C:\>java -jar rohit.jar

Adam Koblentz

Joined: Mar 18, 2011
Posts: 19

Are you sure you're exporting the jar correctly?
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Yes, you need the Spring jars in your classpath in order for it to find Spring classes.

And it is Spring. There is no pluralization of it. It is the Spring Framework.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
Thanks for the inputs - yes we need to put the jar's in the class path
Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
By the way an update on this - i was using maven for the build ... so finally i figured a way out for this . while creating the jars put in all the dependent jars - i am not too sure if it's the correct approach but since the program that i was trying to do is a standalone one i thought of using it ... in pom.xml you can use the following plugin

and create the jar using

and execute as you normally do using
I agree. Here's the link:
subject: NoClassDefFoundError: org/springframework/context/ApplicationContext
It's not a secret anymore!