Reputation: 6881
I'm new to webservice development. I'm using Netbeans 7.0 with the Axis2 plugin and Tomcat 7.
I have a server application that is just a bunch of web methods with no UI or anything, and I created it pretty much following the tutorial at http://netbeans.org/kb/69/websvc/gs-axis.html. I use the Axis2 plugin to deploy to Tomcat.
So when I created my server application, there is no main method or anything. Typically if I want to log to a log4j log file, I'd put something like this in my main method to define where the config file for log4j resides...
PropertyConfigurator.configure("./conf/log4j.properties");
I do this on the webservice client and it works just fine, but of course that has a main method. So where would I put it in a webservice server application that has no main method? I know it doesn't have to be in the main method, but it has to be in some block of code that I know will execute, and I can't really guarantee which of my web methods will be executed first, so I can't really just stick it in one of my web methods.
I did check out other posts on StackOverflow, but didn't really find any that describe what to do in this scenario.
Anyone know the right way to do this?
Upvotes: 0
Views: 893
Reputation: 15104
I would use a ContextListener
:
http://www.java2s.com/Tutorial/Java/0400__Servlet/SetServletContextListenerinwebXML.htm
Upvotes: 1