Monday, March 27, 2006
Property/Variable reference in log4j.properties
environment variable log4j.properties
Problem:
In your log4j.properties file a relative reference to a folder is fine as long as you start the program (eg tomcat) the same way from the same location every time.
Eg: log4j.appender.LOGGER.File=../logs/slide.log
(Ok if you're starting tomcat from CATALINA_HOME/bin/catalina.bat)
If not, you will get FileNotFound exceptions when the parent folder can't be found. In the above example, starting tomcat from a windows service will have the user.dir=C:\WINDOWS\SYSTEM32, so ../logs is C:\WINDOWS\logs & doesn't exist.
Solution:
Make explicit file references using system properties in the log4j.properties file. Note, you can not use environment variables (that's a platform specific concept).
System properties can be set in code or for this purpose should be set with the "-D" JVM option.
With the above tomcat example, most of the important environment variables to tomcat are copied into corresponding system properties if you use the standard scripts.
Eg: in catalina.bat: -Dcatalina.home=%CATALINA_HOME%
This allows you to reference the property using ${...} notation
Eg: log4j.appender.LOGGER.File=${catalina.home}/logs/slide.log
Sunday, March 26, 2006
Missing JAAS Config
"Unable to locate a login configuration" JAAS Tomcat
Problem:
Starting up tomcat as a service on Windows the above error message with stack trace displayed. The file it's referring to as missing is in the folder %CATALINA_HOME%/conf/jaas.config
Solution:
You need to make sure the system property "java.security.auth.login.config"
is defined & this should be a full path to the file. This can be via the -D JVM option. eg:
-Djava.security.auth.login.config=%CATALINA_BASE%\conf\jaas.config
Depending on whether you run tomcat via "catalina.bat" or the windows service will determine the best place to put this option.
Notes:
Ok, not a profound solution to start with but it's a solution with a problem description that will hopefully come up in a similar keyword search. I had to scroll to the 6th search result on http://www.google.com.au/search?hl=en&q=%22Unable+to+locate+a+login+configuration%22+JAAS+Tomcat
which actually isn't too bad.
Monday, March 20, 2006
Tired of googling questions with no answers
The typical sequence of problem solving goes as follows:
- Putting question/error message/keywords in a web search.
- This will almost always find results - in the hundreds & thousands - great!
- Follow links to the search results and I'll find at least one if not dozens of descriptions of the exact same problem scenario.
- Scroll down, follow the links to posted comments/replies. I'll find heaps of people saying they have the same problem ... but no solution. If I'm really unlucky, I'll find the last comment from the original poster saying "Oh forget it, I've resolved the issue ... thanks".
- The wording/phrasing of someone's comment may lead me to thinking about my problem differently, inspire me to try something else and alleluia! The problem is solved and I move on the next one.
Hence the Dev-Answers blog is born.