This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Spring DI help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring DI help" Watch "Spring DI help" New topic

Spring DI help

Matt Zollinhofer
Ranch Hand

Joined: Jul 09, 2004
Posts: 33
We'll just get it out there that I'm very new to Spring and just trying to get my feet wet.

That said, I walked through the tutorial: and everything worked fine. A little bit of my problem is that the tutorial covers a bit too much, I'm working with an old servlet and just trying to wade my way into spring (DI in particular) with. So the basic set up is that my servlet uses a class called KMLCreator, no big deal. It's within that class that I want to inject an object called Config. The Config object is a custom Config object that takes and InputStream of an xml file. The KMLCreator will use the config object to pull a few application config parameters.

I'm really not sure if I'm approaching this correctly, so please feel free to comment on that in general. I hope my little preamble made it clear what I'm attempting to do. The error I get is below.


Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
OK, everything spring related seems fine to me. The problem you're having is that your code can't find kmlservlet_config.xml. Make sure that the file is available in the place your code looks for it. Go into debug mode in your IDE, and see the absolute path of the file referenced in the code, and make sure that its there.

Visit my blog:
Matt Zollinhofer
Ranch Hand

Joined: Jul 09, 2004
Posts: 33
thanks for the response. I put the file at the root of the classpath and up until now I've just been doing:

which has worked fine. I just don't know how to reference the same thing from the spring point of view. Does it just look on the classpath? I'm not exactly sure what you mean about using the debugger to find the absolute path to the file, could you explain that?

subject: Spring DI help
Similar Threads
ERROR - Context initialization failed org.springframework.beans.factory.BeanCreationException
Error getting Spring security 2 to set up in Spring 2.5
java.lang.VerifyError,runtime exception,can anyone explain when or why get this runtime exception
Problem running tomcat - HTTP Status 404
Struts 2 + Spring 2 + JPA + AJAX