benjamin van der veen

Greenhorn
+ Follow
since Sep 11, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by benjamin van der veen

I think I may have committed a deadly sin. I didn't javadoc-comment my code as I wrote it.

Now I'm sitting on close to 50 undocumented files (though not all of them are "public" and require javadoc). I am wondering if there is any software which will step through my source code and let me choose some methods to prepend with javadoc-style comments, and then write out a little skeleton comment, perhaps just with "write description here" placeholders for the method and any applicable @param and @return attributes.

Does this exist or am I going to have to write it myself/do it all by hand?

Thanks,
benjamin
17 years ago
Thanks for the suggestions. Using the getResourceAsStream() method, I got my configuration file to load, but now I'm faced with writing a custom Velocity ResourceLoader to load templates from a .war file. If possible, I'd like to be able to use the same code to load from both the .war and a physical directory (so templates can be edited without modifying the .war file).

I have tried doing some reseach on ServletContext.getResourceAsStream(), but I've come up dry. You guys indicated that it works when your application is deployed as a .war file, but does it behave the same way if your application is not in a .war file, but rather a physical directory structure? Also, suppose I had a "conf" directory in a .war file, but I also had a physical directory called "conf" alongside the .war file. That would render the following code ambiguous:



This is assuming, of course, that you can have both a .war and a physical directory structure in one webapp folder and Tomcat will recognize both. I'm not sure but it seems reasonable that Tomcat might do this. Correct me if I'm wrong.

Thanks, benjamin
17 years ago
My question is rather complicated. I'll do my best to elucidate the issue.

I have written my own web framework based on servlets. Obviously, my framework has it's own XML config file (i.e.: /WEB-INF/myconfig.xml). Now, as I was developing the framework (and a few applications which run on it), I was using NetBeans as my IDE, and used the bundled Tomcat server. Essentially, I let NetBeans take care of all the details of deploying the application. It output the exploded application into a directory, and Tomcat ran it from there. It also output a .war file, but Tomcat wasn't loading it.

Now I've finished the apps and I went through the process of setting up Tomcat, mod_jk, and Apache on the production server. I got it all set up and stuck the .war file which NetBeans made into the proper folder. However, the application didn't work. I checked the log files and determined that Tomcat/mod_jk/Apache are all configured correctly because log messages from my framework are showing up in the Tomcat logs, followed by some revealing exceptions/stack traces: my framework can't find it's configuration file.

I was using the following code to get the absolute path of the root of the web application:




then I could append "/WEB-INF/myconfig.xml", and build it with JDOM. However, the servlet API docs say that ServletContext.getRealPath() returns null if the application is deployed from a .war file. That's why my framework couldn't find its config file. It was looking for "null/WEB-INF/myconfig.xml", which obviously is not valid.

I also explored Class.getResource(). However, as I understand it, this technique will fail when the servlet container doesn't expand .war files (Tomcat does by default, but can be configured to not do so).

So, I guess there are two options, neither of which I know how to do.

1) Build the .war file with the configuration file inside of it, and then somehow load the configuration file using a path relative to the root of the .war file.

2) Or, even better, have the configuration file outside of the .war file, and load it. Somehow. The challenge is in getting the location of the file to my framework. I'm fresh out of ideas.

I would really like to do number two, but I could live with number one.

I really don't know how to explain this dilemma without being so verbose, so I've had limited success googling for solutions. Hence this post.

Any ideas?

Thanks a lot,
benjamin
17 years ago