Trying to make some small changes to Apache’s Velocity engine.
Here’s what I can and can’t do.
I’m making a change to the merge function(). The change I’m making doesn’t matter because I haven’t made it yet. 😉 Right now I am settling for a println statement firing.
I have two references to merge(). If I change the function to mergeBAD() Eclipse tells me that it can’t find merge(). Makes sense right? I used to include in my class build path the two jars that you get when downloading velocity but instead I’ve created a project using the src files provided and used THAT project as a dependency. Again, the fact that is can’t find merge() when I rename it to mergeBAD gives me hope.
But when I am running my web server, hit a breakpoint and step into the merge call, it can’t find the source! I point it to the project yet again, and it “finds” the source, none of the changes I’ve made (specifically the println statements) are hit. They are simply skipped over. 🙁
What on God’s green earth could possibly be causing this? It’s driving me insane. I’ve spent the entire day today trying to figure out what’s wrong. I can’t continue without being able to change Velocity. Exactly what code base is eclipse running the velocity files from?
Many thanks in advance SO! 🙂
This is a typical case of confusion between build classpath and runtime classpath.
Your build classpath contains references to your Java project (containing the changes to Velocity)… but I bet your runtime classpath holds references to the original Velocity JAR files.
Managing build classpath and runtime classpath in Web projects under Eclipse (the WTP – Web Tools Project) has been going through massive changes over the last few WTP releases. We can guide you through. If you physically added Velocity’s JAR files into your
WEB-INF/lib, lets start by removing them.OK, after you remove the
Velocity.jarfile fromWEB-INF/lib, do the following:By following the steps above, we cleaned your Web-App from any reference whatsoever to MyVelocity (your project) or any other Velocity JAR.
Now comes the fun part. I will instruct you how to correctly “add” Java projects to Web projects as dependencies.
Deployment Assembly.Back in the
Deployment Assemblydialog, you should now seeMyVelocitymapped intoWEB-INF/lib/MyVelocity.jar.Click OK.
What we did by that is to map MyVelocity as a
WEB-INF/libdependency. By doing that,MyVelocityis automatically added to the compile-time build-path as well – so it is very important that you don’t add it yourself to the build-path, resulting in duplicate build-path entries.Everything should work for you now. Let me know if you have any problems.
P.S. these instructions are correct if you’re developing a stand-alone WAR project; if your WAR file is a part of an EAR, you may wish (under certain circumstances, for example if
MyVelocityis used by other J2EE modules inside the EAR) to mapMyVelocitydifferently, to a common location; if that’s the case, let me know and I’ll elaborate further.