iTunes 4 tips by Apple
Apple has posted a nice article about various iTunes tips in their knowledge base :
Read
Restarting a webapp via RMIAdapter: why doesn't it work for me?
Restarting a webapp via HTMLAdapter (jmx-console) works fine. Restarting a webapp via RMIAdapter, however, produces a lot of errors, mostly javax.management.InstanceAlreadyExistsException. Reading through the sources I could not find any serious differences between the way the HTMLAdapter invokes an operation on the MBean and the way RMIAdaptor does. The provided Ant task (jbossjmx-ant.jar) doesn't work either. Perhaps someone has a good hint or tip for me?
Writing into multiple files with log4j
Using log statements for low-tech debugging is generally a good thing. Using only one file however may become chaotic especially if you want to trace third party frameworks as well. I faced the problem during the development of my system. When I set the threshold in log4j to DEBUG my logfile was exploding (Struts and Tiles are very talkative).
Thanks to log4j it is possible to use different files for different packages (and their children). First you have to declare the appenders you want to use, e.g. an appender called HIBERNATE:
<appender name="HIBERNATE" class="org.apache.log4j.FileAppender">
<param name="Append" value="false"/>
<param name="File" value="${server.home}/logs/log4j-hibernate.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>
Afterwards you can attach a category to these appenders. This way you can log all statements from Hibernate into one log file, all statements from Struts into another log file and so on:
<category name="cirrus.hibernate"> <priority value="DEBUG" /> <appender-ref ref="HIBERNATE"/> </category>
Tips 'n' Tricks: Prevent NullPointerException in string comparison
Very often I read the following statement:
if (someString.equals("foo")) ...
Now if someString is null this code would produce a nasty NullPointerException. One solution might be:
if ((someString != null) && someString.equals("foo")) ...
But there's a better way:
if ("foo".equals(someString)) ...
Very easy =)
Tips 'n' Tricks: How to keep JSP compilation results with JBoss/Jetty
If you want to keep your JSP compilation results between server restarts you have to tell Jetty where to put the results. Otherwise Jetty will use a different directory on each restart. The simplest way is to add an init-parameter in webdefault.xml:
[code]